问题描述
我正在创建的网站上编写电子邮件系统的简化版。
I'm writing a simplified version of an email system on a site I'm creating.
基本前提是用户可以在网站上互相发送消息,最好的例子是ebay,您可以在网站本身上向其他用户发送消息,并且它基本上像电子邮件一样系统。
The basic premise is users can message each other on the site, best example would be ebay, you can message other users on the site itself and it basically acts as an email system.
我所收到的是消息本身,消息的发件人,发来的消息以及文本。
What I have is the messages themselves, who they're from, to and the text.
我还希望拥有基本的已读/未读和已删除,甚至可能有已发送类别。
I would also like to have basic "read/not read" and "deleted", possibly even "sent" categories.
类似这样的东西:
表结构:
id,从主题,正文到dateTime
id, to, from, subject, body, dateTime
我想知道的是,仅添加 read和删除列到该表,并在我在网站上需要它们时搜索那些特殊条件,或者如果有另一个类别表,然后有一个联接表将消息ID和类别放在一起是更有效/最佳实践id,然后在需要时使用该联接表提供信息?
What I'd like to know is if it makes more sense to just add a "read" and "deleted" column to that table, and search for those particular conditions, when I need them on the site, or if it is more efficient/best practice to have another "categories" table and then have a join table putting a message id with category id, and then using that join table to serve up the info when it's requested?
如果我的问题不能原谅我,我仍然很新
If my question doesn't make sense forgive me, I'm still pretty new at this stuff.
推荐答案
我会添加两列:
read tinyint(1),
deleted tinyint(1)
并将其用作布尔值。
这篇关于数据库效率/结构问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!