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.

Instagram ER diagram

Instagram database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 accounts idBIGINT usernameVARCHAR full_nameVARCHAR bioVARCHAR avatar_urlVARCHAR is_privateBOOLEAN is_verifiedBOOLEAN follower_countINTEGER following_countINTEGER post_countINTEGER created_atTIMESTAMP follows follower_idBIGINT followee_idBIGINT statusVARCHAR requested_atTIMESTAMP responded_atTIMESTAMP posts idBIGINT author_idBIGINT captionVARCHAR location_nameVARCHAR latitudeNUMERIC longitudeNUMERIC like_countINTEGER comment_countINTEGER comments_enabledBOOLEAN created_atTIMESTAMP deleted_atTIMESTAMP post_media idBIGINT post_idBIGINT positionSMALLINT media_typeVARCHAR storage_keyVARCHAR widthINTEGER heightINTEGER duration_msINTEGER alt_textVARCHAR post_likes post_idBIGINT account_idBIGINT created_atTIMESTAMP comments idBIGINT post_idBIGINT author_idBIGINT parent_comment_idBIGINT bodyVARCHAR like_countINTEGER created_atTIMESTAMP stories idBIGINT author_idBIGINT media_typeVARCHAR storage_keyVARCHAR duration_msINTEGER created_atTIMESTAMP expires_atTIMESTAMP highlight_nameVARCHAR story_views story_idBIGINT viewer_idBIGINT viewed_atTIMESTAMP collections idBIGINT owner_idBIGINT nameVARCHAR is_defaultBOOLEAN created_atTIMESTAMP collection_saves collection_idBIGINT post_idBIGINT saved_atTIMESTAMP direct_threads idBIGINT is_groupBOOLEAN titleVARCHAR is_requestBOOLEAN created_by_idBIGINT last_message_atTIMESTAMP direct_thread_membe… thread_idBIGINT account_idBIGINT joined_atTIMESTAMP last_read_message…BIGINT is_mutedBOOLEAN direct_messages idBIGINT thread_idBIGINT sender_idBIGINT bodyVARCHAR shared_post_idBIGINT reply_to_message_…BIGINT created_atTIMESTAMP

Related database schemas