Blog Database Schema database schema
The Blog Database Schema database schema by Colton Bristow has 15 tables (users, subscribers, posts, post_revisions and 11 more), 114 columns and 19 relationships, documented column by column.
- Tables
- 15
- Columns
- 114
- Relationships
- 19
- Enums
- 6
Tables (15)
| Table | Columns | Description |
|---|---|---|
| users | 10 | Authors, editors and admins in one table, separated by role. The slug powers /author/jane-doe. |
| subscribers | 9 | Double opt-in: confirmed_at null means pending and must never be mailed. Unsubscribe is a timestamp, never a delete, so a re-import cannot resurrect them. |
| posts | 15 | published_at in the future IS the scheduling mechanism; no separate queue table. The counts are caches rebuildable from comments and post_views. |
| post_revisions | 8 | Append-only history. posts carries the live version; every prior state including unpublished drafts lives here. |
| categories | 6 | Self-referencing tree, editorially curated. Categories are few and hierarchical; tags are many and flat. |
| post_categories | 3 | is_primary picks the one category used in breadcrumbs and the canonical URL when a post sits in several. |
| tags | 4 | Flat and author-created. usage_count is a cache that drives the tag cloud and stops orphan tags accumulating. |
| post_tags | 2 | |
| media | 12 | A reusable library, not a per-post attachment list. alt_text is not optional in practice: it is both accessibility and image SEO. |
| post_media | 3 | Many-to-many so one image can appear in several posts without being re-uploaded. |
| comments | 11 | user_id null is a guest comment, which is why the author name and email are denormalised here. Self-referencing for threads. |
| comment_reports | 7 | |
| seo_meta | 11 | Exactly one of post_id or category_id is set. The column lengths are deliberate: 70 and 160 are roughly what search results actually render. |
| redirects | 7 | The reason slugs can change safely. status_code is 301 for permanent, 302 for temporary. hit_count shows which old URLs still carry traffic. |
| post_views | 6 | Pre-aggregated per post per day per referrer, not one row per hit. Raw hit logs belong in an analytics pipeline, not the blog database. |
Enums (6)
- user_role
- admin, editor, author, contributor
- post_status
- draft, in_review, scheduled, published, archived
- comment_status
- pending, approved, spam, trashed
- report_reason
- spam, abuse, off_topic, personal_info, other
- media_type
- image, video, audio, document
- subscriber_status
- pending, confirmed, unsubscribed, bounced
Document your own schema
This page is published from DB Planner, a collaborative ER diagram tool. Write the schema in the DBML editor or import it from SQL, then publish docs like these from the project's sharing settings.