-
Notifications
You must be signed in to change notification settings - Fork 0
Database Design
Codex edited this page Apr 28, 2026
·
1 revision
The relational model is centered on a small set of core entities:
userspostslikescommentsview_historyfollowsnotifications
Stores account identity and profile data.
Main columns:
idusernamepassword_hashdisplay_namebiocreated_at
Stores image-based posts created by users.
Main columns:
iduser_idcategorydescriptionimage_urlimage_widthimage_heightcreated_at
Stores user reactions to posts.
Key rule:
- unique
(user_id, post_id)to prevent duplicate likes
Stores post discussion.
Main columns:
iduser_idpost_idbodycreated_at
Tracks recently viewed posts per user.
Key rule:
- unique
(user_id, post_id)with latest-view behavior
Stores the self-referential user follow graph.
Key rule:
- unique
(follower_id, followee_id)
Stores inbox events for likes, comments, and follows.
Main columns:
iduser_idactor_idtypepost_idis_readcreated_at
- Normalized structure for core social features
- Aggregate counts are computed on reads
- Foreign-key cascades keep dependent records consistent
- Search-related indexes support SQL and text-based exploration
- FULLTEXT indexes are created when available, with
LIKEfallback support