Social database schemas

Follows, feeds and posts, modelled for read volume. Counters are denormalised, deletion is soft because posts act as anchors, and every relationship table is indexed in both directions. Every one opens in the free drawDB editor in a click, and is public domain.

9 schemas here, from 11 to 13 tables (109 tables and 758 columns in total), written for PostgreSQL. Each one ships an ER diagram you can open and edit, a column-by-column reference, design notes explaining the trade-offs, and SQL for all six dialects. Recurring themes across the set: follows, messaging, feed, hashtags.

PostgreSQL
Social

Facebook database schema

How a social network models its data: symmetric friendships stored as one canonical row, posts with audience scoping, typed reactions, groups with membership roles, pages, and events with RSVPs.

PostgreSQL
Social

Instagram database schema

How a photo-sharing app models its data: asymmetric follows with pending requests for private accounts, posts carrying an ordered carousel of media, likes and two-level comments, stories that expire, saved collections and direct messages.

PostgreSQL
Social

LinkedIn database schema

How a professional network models its data: profiles with a date-ranged career history, symmetric connections created from invitations, canonical skills with endorsements, company pages, job postings and applications, and a feed.

PostgreSQL
Social

Pinterest database schema

How a visual bookmarking app models its data: images deduplicated by content hash, pins as saves rather than uploads, repins as a self-reference to the source pin, boards with sections and collaborators, follows of both people and boards, and saved searches.

PostgreSQL
Social

Reddit database schema

How a forum models its data: subreddits and subscriptions, link and text posts, arbitrarily deep comment trees stored as materialised paths, narrow vote tables, karma, flairs, and an append-only moderation log with removal reasons.

PostgreSQL
Social

Social network database schema

Followers, feeds and direct messages modelled for read volume: asymmetric follows, one posts table for replies and reposts, narrow like rows, per-participant read pointers and notifications.

PostgreSQL
Social

TikTok database schema

How a short-video app models its data: sounds as first-class rows reused across videos, duets and stitches as self-references, an append-only watch-event log feeding a recommendation feed, plus follows, likes, comments and hashtags.

PostgreSQL
Social

Tinder dating app database schema

How a dating app models its data: profiles with ordered photos, discovery preferences, an append-only swipe log, matches created only on a mutual right swipe, messaging scoped to a match, blocks and reports, and consumable boosts and super likes.

PostgreSQL
Social

Twitter (X) database schema

How a microblogging platform models its data: one tweets table covering tweets, replies, retweets and quotes, an asymmetric follow graph, a fanned-out home timeline, lists, bookmarks, and hashtags and mentions extracted at post time.

other categories