简体   繁体   English

3NF 归一化和分解

[英]3NF Normalization and Decomposition

I am currently in a DB class and working through Normalization, and am running into some trouble.我目前在 DB 课程中,正在完成规范化工作,但遇到了一些麻烦。 Am hoping I can get some assistance working through this.我希望我能得到一些帮助来解决这个问题。 I have searched for the last 30 min and haven't found anything that helps solve my question, but hopefully I'm not searching for the wrong things.我搜索了过去 30 分钟,但没有找到任何有助于解决我的问题的内容,但希望我没有搜索错误的内容。

The question is as follows:问题如下:

Considering the universal Relation考虑普遍关系

EMPLOYEE (ID, First, Last, Team, Dept, Salary)

With the follow set F of functional dependencies使用以下函数依赖集 F

ID -> First
ID -> Last
First, Last -> ID
Last -> Team
ID -> Dept
ID -> Salary
Salary -> Dept

Identify the candidate keys and construction a decomposition of Employee into relations in 3NF that preserve Dependencies.确定候选键并将 Employee 分解为 3NF 中保留依赖关系的关系。

For the candidate keys, I am struggling because when doing an edge diagram, there are incoming dependencies for every single attribute.对于候选键,我很挣扎,因为在绘制边缘图时,每个属性都有传入的依赖关系。 There are no attributes that do not appear on the RHS of the dependencies.没有没有出现在依赖项的 RHS 上的属性。 What I think may be confusing me is that while ID does determine everything, First, Last determines ID .我认为可能让我感到困惑的是,虽然ID确实决定了一切,但First, Last决定了ID So would ID and First, Last both be a candidate key?那么IDFirst, Last都是候选键吗?

I know for the deconstruction, Last -> Team and Salary -> Dept are transitive, but ID has a direct dependency ID -> Dept and ID-> Salary already given.我知道解构, Last -> TeamSalary -> Dept是可传递的,但ID有一个直接依赖ID -> DeptID-> Salary已经给出。

Does that mean I only need two tables, (ID, First, Last, Salary) and (Last, Team) ?这是否意味着我只需要两个表, (ID, First, Last, Salary)(Last, Team)

Or based on the candidate keys question above, do I need (ID, First, Last) (ID, Salary, Dept) (Last, Team)或者根据上面的候选键问题,我需要(ID, First, Last) (ID, Salary, Dept) (Last, Team)

Let me know if any additional info is needed.如果需要任何其他信息,请告诉我。 Thank you.谢谢你。

So would ID and First, Last both be a candidate key?那么 ID 和 First, Last 都是候选键吗?

ID is a candidate key and Last, First is probably a composite index. ID 是一个候选键,而 Last, First 可能是一个复合索引。 It's too common for people to have the same name.人们拥有相同的名字太常见了。

The third normal form can be summed up in one sentence.第三范式可以用一句话概括。 "The columns in the table depend on the key, the whole key, and nothing but the key, so help me Codd." “表中的列依赖于键,整个键,除了键之外什么都没有,所以帮帮我 Codd。”

So, let's take a look at your original description.所以,让我们来看看你的原始描述。

EMPLOYEE (ID, First, Last, Team, Dept, Salary)

First, Last, and Salary would be based on the employee id. First、Last 和 Salary 将基于员工 ID。 One of your dependencies implies that everyone in the department gets the same salary.您的依赖关系之一意味着部门中的每个人都获得相同的薪水。 I don't agree, but whatever.我不同意,但无论如何。

An employee is on one team, and one team can have one or more employees.一个员工在一个团队中,一个团队可以有一个或多个员工。 This is a one to many relationship, which implies a foreign key to a Team table from the Employee table.这是一个一对多的关系,这意味着从 Employee 表到 Team 表的外键。

The same holds for the employee / department relationship.这同样适用于员工/部门关系。 Another foreign key to a Department table from the Employee table.来自员工表的部门表的另一个外键。

There doesn't seem to be any relationship between the Team table and the Department table. Team 表和 Department 表之间似乎没有任何关系。

Salary is a weird field.薪水是一个奇怪的领域。 I'd say it belongs in the Employee table, but the Salary -> Dept relationship is confusing me.我会说它属于 Employee 表,但Salary -> Dept关系让我感到困惑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM