Dating app database schema
Profiles with photos, swipes, mutual matches, messages and blocks.
6 tables, 9 relationships
Opens as a new diagram you can change. Free.
Tables
profiles
- iduuid not null
- display_nametext not null
- birth_datedate not null
- biotext
- latitudenumeric(9,6)
- longitudenumeric(9,6)
- created_attimestamptz not null
profile_photos
- iduuid not null
- profile_id> profilesuuid not null
- urltext not null
- positioninteger not null
- created_attimestamptz not null
swipes
- iduuid not null
- swiper_id> profilesuuid not null
- swiped_id> profilesuuid not null
- likedboolean not null
- created_attimestamptz not null
matches
- iduuid not null
- profile_a_id> profilesuuid not null
- profile_b_id> profilesuuid not null
- unmatched_attimestamptz
- created_attimestamptz not null
match_messages
- iduuid not null
- match_id> matchesuuid not null
- sender_id> profilesuuid not null
- bodytext not null
- created_attimestamptz not null
blocks
- iduuid not null
- blocker_id> profilesuuid not null
- blocked_id> profilesuuid 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 "blocks" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"blocker_id" UUID NOT NULL,
"blocked_id" UUID NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "match_messages" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"match_id" UUID NOT NULL,
"sender_id" UUID NOT NULL,
"body" TEXT NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "matches" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"profile_a_id" UUID NOT NULL,
"profile_b_id" UUID NOT NULL,
"unmatched_at" TIMESTAMPTZ,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "profile_photos" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"profile_id" UUID NOT NULL,
"url" TEXT NOT NULL,
"position" INTEGER DEFAULT 0 NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "profiles" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"display_name" TEXT NOT NULL,
"birth_date" DATE NOT NULL,
"bio" TEXT,
"latitude" NUMERIC(9,6),
"longitude" NUMERIC(9,6),
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "swipes" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"swiper_id" UUID NOT NULL,
"swiped_id" UUID NOT NULL,
"liked" BOOLEAN NOT NULL,
"created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
PRIMARY KEY ("id")
);
ALTER TABLE "profile_photos" ADD CONSTRAINT "fk_profile_photos_profile_id" FOREIGN KEY ("profile_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "swipes" ADD CONSTRAINT "fk_swipes_swiper_id" FOREIGN KEY ("swiper_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "swipes" ADD CONSTRAINT "fk_swipes_swiped_id" FOREIGN KEY ("swiped_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "matches" ADD CONSTRAINT "fk_matches_profile_a_id" FOREIGN KEY ("profile_a_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "matches" ADD CONSTRAINT "fk_matches_profile_b_id" FOREIGN KEY ("profile_b_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "match_messages" ADD CONSTRAINT "fk_match_messages_match_id" FOREIGN KEY ("match_id") REFERENCES "matches" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "match_messages" ADD CONSTRAINT "fk_match_messages_sender_id" FOREIGN KEY ("sender_id") REFERENCES "profiles" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "blocks" ADD CONSTRAINT "fk_blocks_blocker_id" FOREIGN KEY ("blocker_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE "blocks" ADD CONSTRAINT "fk_blocks_blocked_id" FOREIGN KEY ("blocked_id") REFERENCES "profiles" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;More Social & community templates
- Social networkProfiles, follows, posts with media, comments and likes.
- Discussion forumCategories, threads and posts with reactions and moderation reports.
- Chat / messagingDirect and group conversations, messages, attachments and read receipts.
- Meetup groupsInterest groups with members, events at venues and RSVPs.
- Q&A siteQuestions, answers with votes, accepted answers and tags.
- Reviews & ratingsBusinesses reviewed by users, with photos, helpful votes and owner replies.
- Creator membershipsCreators offering paid tiers, supporters' pledges and members-only posts.
- GamificationPoints ledger, levels, badges and streaks for an engaged community.
- Mentorship programmeProgrammes matching mentors with mentees, sessions and feedback.
- Chat app (Firestore)Users, rooms with their members, and messages as a subcollection of each room.
- Activity feed (Cassandra)Each user's feed by time bucket, follower lists both ways, and like counters.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.