【问题标题】:check database design for a blog application检查博客应用程序的数据库设计
【发布时间】:2013-02-07 01:16:16
【问题描述】:

我正在创建一个博客应用程序 - 多个用户可以在其中发布、分享和喜欢博客。

我已经创建了数据库的大纲,但我不确定它是否正确。尽管阅读了外键,但我不明白如何处理外键。

谁能帮我解决这些问题。我心中的一些问题是:-

- should the articles(blogs) details be stored in both 'Table Articles' and 'Table Share' at the time a user publishes an article. Will this help me in writing a php script in showing only the latest and shared articles on top of the page

- should articleid be stored in all tables?

以下是我的数据库的概要

用户

表用户

-userid
-email
-name
-password
-date_of_registration

文章

文章有标题和描述。后来我有计划添加图像,但不是现在。用户可以在注册或登录后发布文章。最新文章显示在页面顶部(与共享文章一起)。

表格文章

-articleid
-userid
-title
-description
-datetime 

评论

用户应该能够评论其他用户的文章 + 发帖人也应该能够评论

表cmets

-commentid
-articleid
-userid
-comment
-datetime

分享

用户应该能够分享他们喜欢的文章。发表文章的人不能再次分享。如果一篇文章已被分享,则它应该位于所有文章(以及最新文章)的顶部。

表共享

-articleid
-userid (the person who shared it)
-datetime

喜欢

用户应该能够喜欢任何文章。

表样

-articleid
-userid (the person who clicked on the like button)

【问题讨论】:

    标签: database foreign-keys relational-database primary-key normalization


    【解决方案1】:
    1. 确保对用户密码进行哈希处理并存储盐。

    2. 选择一个通用的日期命名方案。 “行动”_at 是一个很好的选择。例如,“registered_at”或“created_at”。您应该在单词之间使用下划线以获得最大的兼容性和易读性。

    3. 您确定用户需要登录才能发表评论吗?许多博客系统只允许人们评论一个电子邮件地址。不允许发表评论?

    4. 您可以将“created_at”字段添加到 like 表。确保您在 article_id 和 user_id 上都有一个主键

    5. 共享如何工作?他们与谁分享?

    否则,一个好的开始!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      • 2015-11-03
      相关资源
      最近更新 更多