Digital asset management database schema
Assets in folders with renditions, collections and usage licences.
6 tables, 6 relationships
Opens as a new diagram you can change. Free.
Tables
folders
- iduuid not null
- nametext not null
- parent_id> foldersuuid
- created_attimestamptz not null
assets
- iduuid not null
- folder_id> foldersuuid
- filenametext not null
- mime_typetext not null
- size_bytesbigint not null
- checksumtext not null
- created_attimestamptz not null
renditions
- iduuid not null
- asset_id> assetsuuid not null
- labeltext not null
- urltext not null
- widthinteger
- heightinteger
- created_attimestamptz not null
collections
- iduuid not null
- nametext not null
- descriptiontext
- created_attimestamptz not null
collection_assets
- iduuid not null
- collection_id> collectionsuuid not null
- asset_id> assetsuuid not null
- created_attimestamptz not null
licenses
- iduuid not null
- asset_id> assetsuuid not null
- holdertext not null
- expires_ondate
- termstext 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 "assets" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"folder_id" UUID,
"filename" TEXT NOT NULL,
"mime_type" TEXT NOT NULL,
"size_bytes" BIGINT NOT NULL,
"checksum" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "collection_assets" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"collection_id" UUID NOT NULL,
"asset_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "collections" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "folders" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"name" TEXT NOT NULL,
"parent_id" UUID,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "licenses" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"asset_id" UUID NOT NULL,
"holder" TEXT NOT NULL,
"expires_on" DATE,
"terms" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "renditions" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"asset_id" UUID NOT NULL,
"label" TEXT NOT NULL,
"url" TEXT NOT NULL,
"width" INTEGER,
"height" INTEGER,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "folders" ADD CONSTRAINT "fk_folders_parent_id" FOREIGN KEY ("parent_id") REFERENCES "folders" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "assets" ADD CONSTRAINT "fk_assets_folder_id" FOREIGN KEY ("folder_id") REFERENCES "folders" ("id") ON DELETE SET NULL ON UPDATE NO ACTION;
ALTER TABLE "renditions" ADD CONSTRAINT "fk_renditions_asset_id" FOREIGN KEY ("asset_id") REFERENCES "assets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "collection_assets" ADD CONSTRAINT "fk_collection_assets_collection_id" FOREIGN KEY ("collection_id") REFERENCES "collections" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "collection_assets" ADD CONSTRAINT "fk_collection_assets_asset_id" FOREIGN KEY ("asset_id") REFERENCES "assets" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "licenses" ADD CONSTRAINT "fk_licenses_asset_id" FOREIGN KEY ("asset_id") REFERENCES "assets" ("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.
- News publicationSections, articles with several authors, tags and corrections.
- 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.
- 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.