I need a bit of refresher regarding SQL Database Design, particularly how and what columns to use for a Foreign Key.
我需要对SQL数据库设计进行一些复习,特别是如何以及用于外键的列。
Below are 2 designs I came up with, can please tell which makes more sense? For me, I believe Design 2 seems better..
下面是我想出的2个设计,请告诉哪个更有意义?对我来说,我相信设计2似乎更好..
EDIT:
A Project can contain only 1 Team. A Team can have one or more Team Members. Likewise, a Team Member can be part of one or more Teams. I am using Microsoft Visio, UML Crow Foot Notation to create these images.
一个项目只能包含一个团队。团队可以拥有一个或多个团队成员。同样,团队成员可以成为一个或多个团队的一部分。我正在使用Microsoft Visio,UML Crow Foot Notation来创建这些图像。
The main reason I separated Project from ProjectTeamOrg is to segregate the data, as realistically, I am going to have many elements for a Project and am separating these into their own DB Tables.
我将Project与ProjectTeamOrg分离的主要原因是要隔离数据,实际上,我将为项目提供许多元素,并将它们分离到自己的数据库表中。
Design 1
Design 2
2 个解决方案
#1
The purpose of the database is not clear. You did not explain the flow of data. I am unable to see the Team table. Is it there? or the ProjectTeamOrg is team table.
数据库的目的不明确。您没有解释数据流。我无法看到Team表。它在那里吗?或者ProjectTeamOrg是团队表。
Please explain the flow of data. Then one can be able to help you.
请解释一下数据流。然后一个人可以帮助你。
#2
Tell me about the relation ship between these tables..either one to one (or) one to many.Becoz this relationship helps us to determine which column in the table should have Foreign key.
告诉我这些表之间的关系..一对一(或)一对多.Becoz这种关系有助于我们确定表中哪一列应该有外键。
Go with Design 1
选择设计1
According to the thing which i understood;
根据我理解的东西;
Tablename Columnname Key
Project Projectid Primary
Projectteamorg Projectid Foreign(Reference Project(Projectid))
Projectteammember teamid Primary
Projectteamorg teamid Foreign(Reference Projectteammember(teamid))
#1
The purpose of the database is not clear. You did not explain the flow of data. I am unable to see the Team table. Is it there? or the ProjectTeamOrg is team table.
数据库的目的不明确。您没有解释数据流。我无法看到Team表。它在那里吗?或者ProjectTeamOrg是团队表。
Please explain the flow of data. Then one can be able to help you.
请解释一下数据流。然后一个人可以帮助你。
#2
Tell me about the relation ship between these tables..either one to one (or) one to many.Becoz this relationship helps us to determine which column in the table should have Foreign key.
告诉我这些表之间的关系..一对一(或)一对多.Becoz这种关系有助于我们确定表中哪一列应该有外键。
Go with Design 1
选择设计1
According to the thing which i understood;
根据我理解的东西;
Tablename Columnname Key
Project Projectid Primary
Projectteamorg Projectid Foreign(Reference Project(Projectid))
Projectteammember teamid Primary
Projectteamorg teamid Foreign(Reference Projectteammember(teamid))