Database design 你对我设计的杂志数据库有什么想法?

Database design 你对我设计的杂志数据库有什么想法?,database-design,Database Design,非常感谢您就我为在线杂志设计的db提出建议: -一篇文章可以属于多个类别。 -一篇文章可以有空照片或多张照片。 -一篇文章可以有null或多个标记 Table: `tb_categories` Columns: `cat_id` (Primary Key) `catname` `parent_id` 你的设计看起来很坚固 确保不能为NULL的列被约束为notnull 每个人对这些事情都有不同的看法,但我的建议是: 不要在表名的前面加上“tb_3;”-这是多余的。我们之所以知道它

非常感谢您就我为在线杂志设计的db提出建议:

-一篇文章可以属于多个类别。
-一篇文章可以有空照片或多张照片。
-一篇文章可以有null或多个标记

Table: `tb_categories`
Columns:
`cat_id` (Primary Key)
`catname`
`parent_id`


你的设计看起来很坚固

确保不能为NULL的列被约束为notnull

每个人对这些事情都有不同的看法,但我的建议是:

  • 不要在表名的前面加上“tb_3;”-这是多余的。我们之所以知道它是一个表,是因为它是在使用表的地方使用的,比如from子句和insert或update语句
  • 我更喜欢根据表所代表的内容来命名表。如果一个实体表示一个项目,那么将表命名为“article”。换句话说,使用单数名称。这样想一下——如果我查询表并返回一行,我将得到什么?一篇文章。如果要返回包含文章集合的一行,我会将表命名为articles。(然而,没有“正确”的方法——很多人不同意,喜欢用复数名命名他们的桌子)
  • <> LI>您可能会考虑不要用表名预先标识ID列。我们知道它是一个article\u id,因为它在article表中。然而,在这里,很多人不同意,也不希望在每个表中都看到“ID”列
什么样的建议?你是在问设计是否“正确”吗?或者如何实现设计?我也不是。我会尽力帮助他进行编辑。是的,我的意思是,这个db是正确的?谢谢HPDeveloper。
Table: `tb_articles`
Columns:
`article_id`(Primary Key)
`title`
`subtitle`
`textbody`
`source_id`
`date`
`remark`
Table: `tb_sources`
Columns:
`source_id` (Primary Key)
`sourcename`
Table: `tb_photos`
Columns:
`photo_id` (Primary Key)
`photofilename`
Table: `tb_tags`
Columns:
`tag_id` (Primary Key)
`tagname`
Table: `tb_articles_photo`
Columns:
`article_id` (Foreign Key)
`photo_id` (Foreign Key)
Table: `tb_articles_tags`
Columns:
`article_id` (Foreign Key)
`tag_id` (Foreign Key)
`tb_articles_categories`
Columns:
`article_id` (Foreign Key)
`cat_id` (Foreign Key)