如何为网站实施私人邮件?

时间:2021-05-16 14:32:16

How would you go about implementing private mail functionality such like Bebo/Facebook and other social networking sites?

您将如何实施Bebo / Facebook和其他社交网站等私人邮件功能?

You have the option to post public comments on a member's profile, but you can also send a private mail.

您可以选择在会员的个人资料上发布公开评论,但您也可以发送私人邮件。

I was considering using XML and just storing it as a field in that particular user's record. Does this sound like a bad idea?

我正在考虑使用XML并将其存储为特定用户记录中的字段。这听起来像个坏主意吗?

Anyone have a better suggestion? I am unsure as to which would be the best solution.

有人有更好的建议吗?我不确定哪种解决方案最好。

2 个解决方案

#1


I may have misunderstood what you want, but how about creating a mail table, with for example

我可能误解了你想要的东西,但是如何创建一个邮件表,例如

  • Sender
  • Recipient
  • Subject
  • Message
  • Sent
  • Read (bool)

And then just add a row to that table when someone sends a private message to someone.

然后,当有人向某人发送私人消息时,只需在该表中添加一行。

#2


I would strongly recommend against storing the messages in a field on your user table. This is very likely to result in performance problems as your application grows. As another answer suggested, I'd add a table specifically to store message data. Below is a pseudocode example of what your tables might look like.

我强烈建议不要将消息存储在用户表的字段中。随着应用程序的增长,这很可能会导致性能问题。正如另一个答案所示,我将添加一个专门用于存储消息数据的表。下面是您的表可能是什么样的伪代码示例。

UserTable
{
    ID INT, -- a unique system generated ID
    USER_ID CHAR(20), -- also unique, this is a user provided ID
    FIRST_NAME CHAR(40),
    LAST_NAME CHAR(40),
    BIRTH_DATE DATE 
}

UserEmailTable
{
    ID INT, -- a unique system generated ID
    USER_ID CHAR(20), -- this ties the entry to the record on UserTable
    EMAIL_ADDR CHAR(128), -- user provided email
    PRIORITY INT, -- Specifies the users 0..N-th address
}

MailTable
{
    ID INT, -- a unique system generated ID
    SENDER_ID INT, -- this ties the entry to the record on UserTable
    RECIPIENT_ID INT, -- this ties the entry to the record on UserTable
    CREATE_DATE DATE,  -- record when the message was created by sender
    READ_DATE DATE,  -- record when the message was read by recipient
    PRIVATE BOOL, -- indicates if this is a private message
    MESSAGE BLOB -- the message body
}

Please keep in mind, this is just an example and it may not address the specific concerns of your application.

请记住,这只是一个示例,它可能无法解决您的应用程序的具体问题。

One final thought: Are you actually planning to store XML in field directly or using some sort of XML<-->SQL mapping tool? If you are storing the XML directly, you may not taking advantage of the abilities of your database. Your concerns about performance are valid, but a well designed & tuned database should easily be able to handle millions of records in a single table.

最后一个想法:您是否真的计划直接在字段中存储XML或使用某种XML < - > SQL映射工具?如果直接存储XML,则可能无法利用数据库的功能。您对性能的担忧是有效的,但精心设计和调整的数据库应该能够轻松地在单个表中处理数百万条记录。

Hope that helps.

希望有所帮助。

#1


I may have misunderstood what you want, but how about creating a mail table, with for example

我可能误解了你想要的东西,但是如何创建一个邮件表,例如

  • Sender
  • Recipient
  • Subject
  • Message
  • Sent
  • Read (bool)

And then just add a row to that table when someone sends a private message to someone.

然后,当有人向某人发送私人消息时,只需在该表中添加一行。

#2


I would strongly recommend against storing the messages in a field on your user table. This is very likely to result in performance problems as your application grows. As another answer suggested, I'd add a table specifically to store message data. Below is a pseudocode example of what your tables might look like.

我强烈建议不要将消息存储在用户表的字段中。随着应用程序的增长,这很可能会导致性能问题。正如另一个答案所示,我将添加一个专门用于存储消息数据的表。下面是您的表可能是什么样的伪代码示例。

UserTable
{
    ID INT, -- a unique system generated ID
    USER_ID CHAR(20), -- also unique, this is a user provided ID
    FIRST_NAME CHAR(40),
    LAST_NAME CHAR(40),
    BIRTH_DATE DATE 
}

UserEmailTable
{
    ID INT, -- a unique system generated ID
    USER_ID CHAR(20), -- this ties the entry to the record on UserTable
    EMAIL_ADDR CHAR(128), -- user provided email
    PRIORITY INT, -- Specifies the users 0..N-th address
}

MailTable
{
    ID INT, -- a unique system generated ID
    SENDER_ID INT, -- this ties the entry to the record on UserTable
    RECIPIENT_ID INT, -- this ties the entry to the record on UserTable
    CREATE_DATE DATE,  -- record when the message was created by sender
    READ_DATE DATE,  -- record when the message was read by recipient
    PRIVATE BOOL, -- indicates if this is a private message
    MESSAGE BLOB -- the message body
}

Please keep in mind, this is just an example and it may not address the specific concerns of your application.

请记住,这只是一个示例,它可能无法解决您的应用程序的具体问题。

One final thought: Are you actually planning to store XML in field directly or using some sort of XML<-->SQL mapping tool? If you are storing the XML directly, you may not taking advantage of the abilities of your database. Your concerns about performance are valid, but a well designed & tuned database should easily be able to handle millions of records in a single table.

最后一个想法:您是否真的计划直接在字段中存储XML或使用某种XML < - > SQL映射工具?如果直接存储XML,则可能无法利用数据库的功能。您对性能的担忧是有效的,但精心设计和调整的数据库应该能够轻松地在单个表中处理数百万条记录。

Hope that helps.

希望有所帮助。