Email & mailbox service database schema

How a webmail service models its data: labels applied many-to-many instead of IMAP folders, one stored copy per message, conversation threading, attachments deduplicated by content hash, delivery filters, drafts, read state, spam scoring and quota.

Email Service ER diagram

Email & mailbox service database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 11 n1 n1 n1 n1 n1 n1 n1 accounts idBIGINT email_addressVARCHAR display_nameVARCHAR password_hashVARCHAR timezoneVARCHAR quota_bytesBIGINT used_bytesBIGINT statusVARCHAR created_atTIMESTAMPTZ labels idBIGINT account_idBIGINT nameVARCHAR parent_label_idBIGINT label_typeVARCHAR colorVARCHAR is_hiddenBOOLEAN sort_orderINTEGER threads idBIGINT account_idBIGINT subject_normalisedVARCHAR message_countINTEGER last_message_atTIMESTAMPTZ snippetVARCHAR has_unreadBOOLEAN has_attachmentsBOOLEAN messages idBIGINT account_idBIGINT thread_idBIGINT rfc822_message_idVARCHAR in_reply_toVARCHAR from_addressVARCHAR from_nameVARCHAR subjectVARCHAR body_textTEXT body_htmlTEXT size_bytesINTEGER sent_atTIMESTAMPTZ received_atTIMESTAMPTZ is_readBOOLEAN is_starredBOOLEAN is_draftBOOLEAN spam_scoreDECIMAL snoozed_untilTIMESTAMPTZ message_labels message_idBIGINT label_idBIGINT applied_atTIMESTAMPTZ applied_byVARCHAR message_recipients idBIGINT message_idBIGINT recipient_typeVARCHAR addressVARCHAR display_nameVARCHAR positionSMALLINT attachment_blobs idBIGINT content_sha256CHAR size_bytesBIGINT content_typeVARCHAR storage_keyVARCHAR reference_countINTEGER first_seen_atTIMESTAMPTZ attachments idBIGINT message_idBIGINT blob_idBIGINT filenameVARCHAR declared_content_…VARCHAR is_inlineBOOLEAN content_idVARCHAR part_pathVARCHAR drafts idBIGINT account_idBIGINT message_idBIGINT thread_idBIGINT in_reply_to_messa…BIGINT autosave_versionINTEGER updated_atTIMESTAMPTZ send_atTIMESTAMPTZ filters idBIGINT account_idBIGINT nameVARCHAR match_modeVARCHAR priorityINTEGER stop_processingBOOLEAN is_enabledBOOLEAN created_atTIMESTAMPTZ filter_conditions idBIGINT filter_idBIGINT fieldVARCHAR operatorVARCHAR valueVARCHAR negateBOOLEAN filter_actions idBIGINT filter_idBIGINT actionVARCHAR label_idBIGINT forward_addressVARCHAR positionSMALLINT spam_verdicts idBIGINT message_idBIGINT engineVARCHAR scoreDECIMAL verdictVARCHAR spf_resultVARCHAR dkim_resultVARCHAR dmarc_resultVARCHAR matched_rulesJSONB evaluated_atTIMESTAMPTZ

Related database schemas