Auf*_*ind 0 erd database-design
当然是一个noobish 问题,但我还是会问它。也许别人会感激。^^
我对 MySQL 越来越熟悉,并且我试图理解创建结构良好的数据库的概念。目前我正在阅读实体关系图(ERD),我问自己:
如果我有三个由第四个链接的表格,例如: 由一个或多个作者撰写的一本书,并且每个作者都在一个或多个国家出版。
authors books countries
id | name id | book id | publishedInCountry
1 | ... 1 | ... 1 | ...
1 | ... 2 | ... 2 | ...
1 | ... 2 | ... 3 | ...
4 | ... 1 | ... 3 | ...
linkTable
idOfAuthor | idOfBook | idOfCountry
1 | 1 | 1
...
Run Code Online (Sandbox Code Playgroud)
这些 ERD 会是什么样子?
附加信息
我想到了:
[authors]
-- < 是 > 的作者 -- [books]
-- < 发表于 >[countries]
但我如何适应linkTable
?
据我所知,
您需要两个单独的链接表,因为它们是不相关的,一个用于将许多书籍链接到许多作者,另一个用于将许多国家链接到许多书籍。
linkTable Author-Book
idOfAuthor | idOfBook
1 | 1
linkTable2 Book-Country
idOfBook | idOfCountry
1 | 1
Run Code Online (Sandbox Code Playgroud)