media_assets table
The media_assets table in the Reddit Clone Database Schema schema has 14 columns, keyed by id, with 1 foreign key to users. 3 columns in post_media, chat_messages and ads reference it.
The upload registry, deliberately separate from anything that references it. checksum is indexed so an identical re-upload deduplicates, and status exists because a video is referenced by a post long before transcoding finishes.
Columns (14)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| uploader_id | uuid | references users.id | |
| kind | media_kind | not null | |
| storage_key | varchar(500) | unique, not null | |
| url | varchar(2000) | not null | |
| thumbnail_url | varchar(500) | ||
| mime_type | varchar(100) | not null | |
| byte_size | bigint | not null | |
| width | integer | ||
| height | integer | ||
| duration_seconds | integer | ||
| checksum | varchar(128) | ||
| status | media_status | not null | |
| created_at | timestamptz | not null |
Indexes (3)
(uploader_id, created_at)(checksum)(status)
Relationships
media_assets.uploader_idreferencesusers.idpost_media.media_asset_idreferencesmedia_assetschat_messages.media_asset_idreferencesmedia_assetsads.creative_asset_idreferencesmedia_assets