博客和评论使用哪个唯一 ID?
这是一个由此处另一个问题的后果引起的问题: 拥有两个单独的用户表还是一个更好?
假设我有两种类型的用户,一个作者和一个读者,每个用户都存储在与主帐户表相关的关系表中,如下所示
TABLE Accounts {
id
email
password
salt
created
modified
}
TABLE reader {
id
user_id
...
}
TABLE author {
id
user_id
...
}
:作者帖子博客,我应该使用作者表中的唯一 ID 还是帐户表中的唯一 ID 来标记博客?读者评论也是如此 - 我应该使用读者表唯一 ID 还是帐户表唯一 ID 来标记评论?
所以,基本上要么:
TABLE Blogs {
id
author_id
}
要么
TABLE Blogs {
id
account_id
}
哪个稍后不太可能反击?
This is a question that arose from the consequences of another question here: Is it better to have two separate user tables or one?
Assuming I have two types of users, an Author and a Reader, each stored in relational tables keyed to a main Accounts table like so:
TABLE Accounts {
id
email
password
salt
created
modified
}
TABLE reader {
id
user_id
...
}
TABLE author {
id
user_id
...
}
When an Author posts a blog, should I tag the blog with the unique id from the Authors table, or the unique id from the Accounts table? Same goes with reader comments - should I tag the comment with the Reader table unique id, or the Account table unique id?
So, basically either:
TABLE Blogs {
id
author_id
}
OR
TABLE Blogs {
id
account_id
}
Which is less likely to bite back later on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,用户可以是管理员和作者。您可以通过查看找到他们的博客
获取与此 user_id 匹配的博客。如果您有帐户类型相关字段
然后将它们全部放入“配置文件”表中。
So a user can be an admin, and an author. You can find their blogs by looking
for a matching blog for this user_id. If you have account type dependant fields
then place them all in the "profile" table.
只有你才能完整回答,但我的直觉告诉我博客条目应该由作者标记。从概念上讲,使用帐户的唯一原因是非作者可以创建(作者)博客文章。到目前为止,根据所提供的信息,情况似乎并非如此。
请注意,我还认为所有作者都应该是用户:每个人都是用户,但只有某些用户也具有作者身份。
Only you can answer fully, but my gut says that the blog entries should be tagged by author. The only reason to use account conceptually would be if a non-author can create (author) a blog post. So far, with the info provided, this does not look to be the case.
Note that I also think that all authors should be users: everybody is a user, but only some users also have authorship status.