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.

Reddit ER diagram

Reddit database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 users idBIGINT usernameVARCHAR emailVARCHAR post_karmaINTEGER comment_karmaINTEGER is_suspendedBOOLEAN created_atTIMESTAMP subreddits idBIGINT nameVARCHAR titleVARCHAR descriptionTEXT visibilityVARCHAR is_nsfwBOOLEAN subscriber_countINTEGER created_by_idBIGINT created_atTIMESTAMP subscriptions subreddit_idBIGINT user_idBIGINT is_favoriteBOOLEAN subscribed_atTIMESTAMP posts idBIGINT subreddit_idBIGINT author_idBIGINT kindVARCHAR titleVARCHAR urlVARCHAR bodyTEXT flair_idBIGINT scoreINTEGER comment_countINTEGER is_lockedBOOLEAN removed_atTIMESTAMP created_atTIMESTAMP comments idBIGINT post_idBIGINT author_idBIGINT parent_comment_idBIGINT pathVARCHAR depthSMALLINT bodyTEXT scoreINTEGER is_removedBOOLEAN created_atTIMESTAMP post_votes post_idBIGINT user_idBIGINT valueSMALLINT created_atTIMESTAMP comment_votes comment_idBIGINT user_idBIGINT valueSMALLINT created_atTIMESTAMP moderators subreddit_idBIGINT user_idBIGINT permissionsVARCHAR added_by_idBIGINT added_atTIMESTAMP removal_reasons idBIGINT subreddit_idBIGINT titleVARCHAR messageTEXT positionSMALLINT is_activeBOOLEAN mod_actions idBIGINT subreddit_idBIGINT moderator_idBIGINT actionVARCHAR target_post_idBIGINT target_comment_idBIGINT target_user_idBIGINT removal_reason_idBIGINT noteVARCHAR created_atTIMESTAMP flairs idBIGINT subreddit_idBIGINT kindVARCHAR textVARCHAR background_colorCHAR is_mod_onlyBOOLEAN user_flairs subreddit_idBIGINT user_idBIGINT flair_idBIGINT text_overrideVARCHAR assigned_atTIMESTAMP

Related database schemas