media table
The media table in the Blog Database Schema schema has 12 columns, keyed by id, with 1 foreign key to users. 2 columns in posts and post_media reference it.
A reusable library, not a per-post attachment list. alt_text is not optional in practice: it is both accessibility and image SEO.
Columns (12)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| uploaded_by | uuid | references users.id | |
| type | media_type | not null | |
| url | varchar(500) | not null | |
| thumbnail_url | varchar(500) | ||
| alt_text | varchar(500) | ||
| caption | varchar(500) | ||
| mime_type | varchar(120) | ||
| width | integer | ||
| height | integer | ||
| size_bytes | bigint | ||
| created_at | timestamptz | not null |
Indexes (1)
(uploaded_by, created_at)
Relationships
media.uploaded_byreferencesusers.idposts.featured_media_idreferencesmediapost_media.media_idreferencesmedia