简体   繁体   English

数据库基础电子邮件系统的最佳数据库设计是什么?

[英]what would be a good db design for database base email system?

I have a simple table like this in mind to create a db base email system, is this the best approach ? 我有一个像这样的简单表可以创建一个基于数据库的电子邮件系统,这是最好的方法吗?

TABLE `message`
      - id
      - parent_id
      - message
      - subject
      - created_on
      - is_draft
      - sender_profile_id      


TABLE `email_message`
      - id
      - is_read
      - is_deleted
      - message_id
      - profile_id

case 1: profile A sending email to profile B, and B Replies back (one to one communication) 情况1:个人资料A向个人资料B发送电子邮件,然后B回复(一对一通讯)

INSERT INTO `message` (`id`, `parent_id`, `message`, `subject`, `created_on`, `is_draft`, `sender_profile_id`) VALUES
(1, 0, 'Hi what''s up how are u', 'Hi', '2010-12-08 11:27:54', 0, 1),
(2, 1, 'yeah i am gud', 0, '2010-12-08 11:28:19', 0, 2);

INSERT INTO `email_message` (`id`, `is_read`, `is_deleted`, `message_id`, `profile_id`) VALUES
(1, 1, 0, 1, 2),
(2, 1, 0, 2, 1);

case 2: 情况2:

-Profile A sending email to profile B,C, D. -配置文件A向配置文件B,C,D发送电子邮件。

-Profile B repling back all to whole group. -配置文件B将全部重新发送回整个组。

-A replying again to whole group. -对整个小组的再次答复。

-C replies to A only -C仅回复A

INSERT INTO `message` (`id`, `parent_id`, `message`, `subject`, `created_on`, `is_draft`, `receiver_profile_id`) VALUES
(3, 0, 'Hi what''s up how are u', 'Hi', '2010-12-08 11:27:54', 0, 1),
(4, 3, 'yeah i am gud.', 0, '2010-12-08 11:28:19', 0, 2),
(5, 3, 'why are u gud?', 0, '2010-12-08 11:28:19', 0, 1),
(6, 3, 'what?', 0, '2010-12-08 11:28:19', 0, 3);

INSERT INTO `email_message` (`id`, `is_read`, `is_deleted`, `message_id`, `profile_id`) VALUES
(3, 1, 0, 3, 2),
(4, 0, 0, 3, 3),
(5, 0, 0, 3, 4),        

(6, 0, 0, 4, 1),
(7, 0, 0, 4, 3),
(8, 0, 0, 4, 4),

(3, 0, 0, 5, 2),
(4, 0, 0, 5, 3),
(5, 0, 0, 5, 4),

(6, 0, 0, 6, 1);

I feel like a single table would be a lot easier to impliment : 我觉得单张表的隐含性要容易得多:

TABLE Message - MessageId (GUID) - ParentId (GUID) - Subject - Message - To - Sender - CreatedOn - isDraft - isDeleted - isRead TABLE消息-MessageId(GUID)-ParentId(GUID)-主题-消息-收件人-发件人-CreatedOn-isDraft-isDeleted-isRead

If you are sending an email to a group, just create multiple records with different "To" entries 如果您要向网上论坛发送电子邮件,只需使用不同的“收件人”条目创建多个记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM