Templates/Content & media

Podcast hosting database schema

Shows, episodes, hosts and download stats.

5 tables, 4 relationships

Opens as a new diagram you can change. Free.

Tables

shows

  • iduuid not null
  • titletext not null
  • descriptiontext
  • rss_slugtext not null
  • created_attimestamptz not null

hosts

  • iduuid not null
  • nametext not null
  • biotext
  • created_attimestamptz not null

show_hosts

  • iduuid not null
  • show_id> showsuuid not null
  • host_id> hostsuuid not null
  • created_attimestamptz not null

episodes

  • iduuid not null
  • show_id> showsuuid not null
  • titletext not null
  • audio_urltext not null
  • duration_secondsinteger not null
  • published_attimestamptz
  • created_attimestamptz not null

downloads

  • iduuid not null
  • episode_id> episodesuuid not null
  • countrytext
  • apptext
  • downloaded_attimestamptz 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 "downloads" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "episode_id" UUID NOT NULL,
  "country" TEXT,
  "app" TEXT,
  "downloaded_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "episodes" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "show_id" UUID NOT NULL,
  "title" TEXT NOT NULL,
  "audio_url" TEXT NOT NULL,
  "duration_seconds" INTEGER NOT NULL,
  "published_at" TIMESTAMPTZ,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "hosts" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "bio" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "show_hosts" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "show_id" UUID NOT NULL,
  "host_id" UUID NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "shows" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "title" TEXT NOT NULL,
  "description" TEXT,
  "rss_slug" TEXT NOT NULL UNIQUE,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "show_hosts" ADD CONSTRAINT "fk_show_hosts_show_id" FOREIGN KEY ("show_id") REFERENCES "shows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "show_hosts" ADD CONSTRAINT "fk_show_hosts_host_id" FOREIGN KEY ("host_id") REFERENCES "hosts" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "episodes" ADD CONSTRAINT "fk_episodes_show_id" FOREIGN KEY ("show_id") REFERENCES "shows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "downloads" ADD CONSTRAINT "fk_downloads_episode_id" FOREIGN KEY ("episode_id") REFERENCES "episodes" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

More Content & media templates

Start with one diagram, free

One diagram with two branches, no card needed. Upgrade when your team needs more.