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.

Facebook ER diagram

Facebook 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 emailVARCHAR vanity_urlVARCHAR display_nameVARCHAR birthdateDATE hometownVARCHAR friend_countINTEGER default_post_audi…VARCHAR created_atTIMESTAMP friendships user_low_idBIGINT user_high_idBIGINT statusVARCHAR requested_by_idBIGINT requested_atTIMESTAMP accepted_atTIMESTAMP friend_lists idBIGINT owner_idBIGINT nameVARCHAR is_systemBOOLEAN created_atTIMESTAMP friend_list_members list_idBIGINT member_idBIGINT added_atTIMESTAMP posts idBIGINT author_idBIGINT group_idBIGINT page_idBIGINT bodyTEXT attachmentJSONB audienceVARCHAR audience_list_idBIGINT shared_post_idBIGINT reaction_countINTEGER comment_countINTEGER created_atTIMESTAMP edited_atTIMESTAMP reactions post_idBIGINT user_idBIGINT reaction_typeVARCHAR created_atTIMESTAMP comments idBIGINT post_idBIGINT author_idBIGINT parent_comment_idBIGINT bodyTEXT reaction_countINTEGER created_atTIMESTAMP groups idBIGINT nameVARCHAR slugVARCHAR descriptionTEXT privacyVARCHAR requires_approvalBOOLEAN member_countINTEGER created_by_idBIGINT created_atTIMESTAMP group_members group_idBIGINT user_idBIGINT roleVARCHAR statusVARCHAR joined_atTIMESTAMP pages idBIGINT nameVARCHAR slugVARCHAR categoryVARCHAR is_verifiedBOOLEAN follower_countINTEGER owner_user_idBIGINT created_atTIMESTAMP page_follows page_idBIGINT user_idBIGINT notification_levelVARCHAR followed_atTIMESTAMP events idBIGINT titleVARCHAR descriptionTEXT host_user_idBIGINT host_page_idBIGINT group_idBIGINT starts_atTIMESTAMP ends_atTIMESTAMP timezoneVARCHAR venue_nameVARCHAR is_onlineBOOLEAN privacyVARCHAR created_atTIMESTAMP event_rsvps event_idBIGINT user_idBIGINT responseVARCHAR guest_countSMALLINT responded_atTIMESTAMP

Related database schemas