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.

ER diagram of the Blog Database Schema schema, showing 15 tables and their relationships
FIG. 1: entity relationship diagram, 15 tables
Tables
15
Columns
114
Relationships
19
Enums
6

Tables (15)

Tables in the Blog Database Schema schema
TableColumnsDescription
users10Authors, editors and admins in one table, separated by role. The slug powers /author/jane-doe.
subscribers9Double 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.
posts15published_at in the future IS the scheduling mechanism; no separate queue table. The counts are caches rebuildable from comments and post_views.
post_revisions8Append-only history. posts carries the live version; every prior state including unpublished drafts lives here.
categories6Self-referencing tree, editorially curated. Categories are few and hierarchical; tags are many and flat.
post_categories3is_primary picks the one category used in breadcrumbs and the canonical URL when a post sits in several.
tags4Flat and author-created. usage_count is a cache that drives the tag cloud and stops orphan tags accumulating.
post_tags2
media12A reusable library, not a per-post attachment list. alt_text is not optional in practice: it is both accessibility and image SEO.
post_media3Many-to-many so one image can appear in several posts without being re-uploaded.
comments11user_id null is a guest comment, which is why the author name and email are denormalised here. Self-referencing for threads.
comment_reports7
seo_meta11Exactly one of post_id or category_id is set. The column lengths are deliberate: 70 and 160 are roughly what search results actually render.
redirects7The reason slugs can change safely. status_code is 301 for permanent, 302 for temporary. hit_count shows which old URLs still carry traffic.
post_views6Pre-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.

More published database schemas