WhatsApp messaging database schema

How a mobile messenger models its data: accounts keyed by phone number, linked devices, private contacts, direct and group chats as one entity, messages with media and replies, per-recipient delivery and read receipts, and disappearing messages with a TTL.

Whatsapp ER diagram

WhatsApp messaging database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 users idBIGINT phone_e164VARCHAR display_nameVARCHAR about_textVARCHAR avatar_urlVARCHAR last_seen_atTIMESTAMP registered_atTIMESTAMP devices idBIGINT user_idBIGINT platformVARCHAR is_primaryBOOLEAN identity_keyVARCHAR push_tokenVARCHAR app_versionVARCHAR linked_atTIMESTAMP last_active_atTIMESTAMP contacts idBIGINT owner_user_idBIGINT contact_user_idBIGINT phone_e164VARCHAR local_nameVARCHAR is_favouriteBOOLEAN synced_atTIMESTAMP chats idBIGINT kindVARCHAR subjectVARCHAR descriptionVARCHAR avatar_urlVARCHAR created_by_user_idBIGINT disappearing_ttl_…INTEGER only_admins_can_p…BOOLEAN last_message_atTIMESTAMP created_atTIMESTAMP chat_participants idBIGINT chat_idBIGINT user_idBIGINT roleVARCHAR joined_atTIMESTAMP left_atTIMESTAMP is_muted_untilTIMESTAMP is_pinnedBOOLEAN is_archivedBOOLEAN media idBIGINT uploaded_by_user_…BIGINT kindVARCHAR object_urlVARCHAR encryption_key_hi…VARCHAR content_typeVARCHAR size_bytesBIGINT duration_secondsINTEGER width_pxINTEGER height_pxINTEGER thumbnail_blobBYTEA uploaded_atTIMESTAMP messages idBIGINT chat_idBIGINT sender_user_idBIGINT media_idBIGINT reply_to_message_…BIGINT bodyTEXT kindVARCHAR statusVARCHAR is_forwardedBOOLEAN sent_atTIMESTAMP edited_atTIMESTAMP expires_atTIMESTAMP deleted_atTIMESTAMP message_receipts message_idBIGINT recipient_user_idBIGINT delivered_atTIMESTAMP read_atTIMESTAMP played_atTIMESTAMP failed_reasonVARCHAR reactions message_idBIGINT user_idBIGINT emojiVARCHAR reacted_atTIMESTAMP blocks idBIGINT blocker_user_idBIGINT blocked_user_idBIGINT created_atTIMESTAMP group_invite_links codeVARCHAR chat_idBIGINT created_by_user_idBIGINT is_activeBOOLEAN requires_admin_ap…BOOLEAN created_atTIMESTAMP revoked_atTIMESTAMP

Related database schemas