News publication database schema
Sections, articles with several authors, tags and corrections.
7 tables, 6 relationships
Opens as a new diagram you can change. Free.
Tables
sections
- iduuid not null
- nametext not null
- slugtext not null
- created_attimestamptz not null
authors
- iduuid not null
- nametext not null
- bylinetext
- created_attimestamptz not null
articles
- iduuid not null
- section_id> sectionsuuid not null
- headlinetext not null
- standfirsttext
- bodytext not null
- published_attimestamptz
- created_attimestamptz not null
article_authors
- iduuid not null
- article_id> articlesuuid not null
- author_id> authorsuuid not null
- created_attimestamptz not null
tags
- iduuid not null
- nametext not null
- created_attimestamptz not null
article_tags
- iduuid not null
- article_id> articlesuuid not null
- tag_id> tagsuuid not null
- created_attimestamptz not null
corrections
- iduuid not null
- article_id> articlesuuid not null
- notetext not null
- created_attimestamptz not null
As PostgreSQL
The same diagram exports to MySQL, MariaDB, SQLite, SQL Server and Oracle, and to Prisma, Drizzle, SQLAlchemy and Convex models.
CREATE TABLE "article_authors" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"article_id" UUID NOT NULL,
"author_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "article_tags" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"article_id" UUID NOT NULL,
"tag_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "articles" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"section_id" UUID NOT NULL,
"headline" TEXT NOT NULL,
"standfirst" TEXT,
"body" TEXT NOT NULL,
"published_at" TIMESTAMPTZ,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "authors" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"byline" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "corrections" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"article_id" UUID NOT NULL,
"note" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "sections" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL UNIQUE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "tags" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL UNIQUE,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "articles" ADD CONSTRAINT "fk_articles_section_id" FOREIGN KEY ("section_id") REFERENCES "sections" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "article_authors" ADD CONSTRAINT "fk_article_authors_article_id" FOREIGN KEY ("article_id") REFERENCES "articles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "article_authors" ADD CONSTRAINT "fk_article_authors_author_id" FOREIGN KEY ("author_id") REFERENCES "authors" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "article_tags" ADD CONSTRAINT "fk_article_tags_article_id" FOREIGN KEY ("article_id") REFERENCES "articles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "article_tags" ADD CONSTRAINT "fk_article_tags_tag_id" FOREIGN KEY ("tag_id") REFERENCES "tags" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "corrections" ADD CONSTRAINT "fk_corrections_article_id" FOREIGN KEY ("article_id") REFERENCES "articles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;More Content & media templates
- Blog / CMSAuthors, posts, categories (many-to-many) and threaded comments.
- Headless CMSContent types with fields, localised entries, versions and assets.
- Podcast hostingShows, episodes, hosts and download stats.
- Video streamingTitles with seasons and episodes, viewer profiles, watch history and ratings.
- Music streamingArtists, albums and tracks, listener playlists and play counts.
- Photo sharingAlbums of photos with tags, likes and comments.
- Wiki / knowledge baseSpaces of nested pages with revisions, attachments and links between pages.
- Email newsletterPublications, subscribers, issues and per-send open and click tracking.
- Digital asset managementAssets in folders with renditions, collections and usage licences.
- Blog with comments (MongoDB)Authors, posts with embedded tags and SEO fields, comments by reference, and sessions that expire.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.