简体   繁体   English

3NF正常化

[英]3NF normalization

I have to normalize the following in 3NF: 我必须在3NF中规范化以下内容:

Service (Service_ID, Service Item, service item cost, date of service)  
Customer (customer ID, customer name, customer telephone number, customer address)  
Vehicle (Vehicle ID, vehicle make, vehicle model, vehicle year)  
Parts (Parts ID, part code, part describtion, part cost)

What I got after normalization: 标准化后得到的结果:

Service (Service_ID (PK), Service Item, service item cost, date of service, Vehicle_ID (FK))  
Customer (customer ID (PK), customer name, customer telephone number, customer address)  
Vehicle (Vehicle ID (PK), vehicle make, vehicle model, vehicle year, Customer_ID (FK))  
Parts (Parts ID (PK), part code, part describtion, part cost, Vehicle_ID (FK))

Do you think I am on completely the wrong track? 你觉得我完全走错了路吗?

Starting relation 开始关系

  • Service (Service_ID, Service Item, service item cost, date of service) 服务(Service_ID,服务项目,服务项目成本,服务日期)

Ending relation 结束关系

  • Service (Service_ID (PK), Service Item, service item cost, date of service, Vehicle_ID (FK)) 服务(Service_ID(PK),服务项目,服务项目成本,服务日期,Vehicle_ID(FK))

Normalization up to 3NF identifies several kinds of functional dependencies, and removes the troublesome ones by projection. 标准化高达3NF可识别多种功能依赖关系,并通过投影消除麻烦的问题。 (By creating another relation.) If you remove a troublesome dependency in a relation by projection, it always ends up with fewer attributes than it started with. (通过创建另一种关系。)如果通过投影删除关系中的麻烦依赖关系,它总是以比开始时更少的属性结束。

Your relation "Service" ends up with more columns than you started with. 您的关系“服务”最终会有比您开始时更多的列。 While it makes sense to record which vehicle the service applies to, that can't possibly have anything to do with normalization, based solely on what you started with. 虽然记录服务所适用的车辆是有意义的,但这完全取决于您的开始,这与标准化无关。

Identifying a missing foreign key, while unarguably an important thing to do, isn't part of normalization per se. 识别丢失的外键虽然无可争议地是一件重要的事情,但它本身并不是标准化的一部分。 Starting with {Service_ID, Service Item, service item cost, date of service, Vehicle_id, vehicle make, vehicle model, vehicle year}, normalization would have said that Service_ID -> Vehicle_ID, and Vehicle_ID -> vehicle make, vehicle model, and vehicle year. 从{Service_ID,服务项目,服务项目成本,服务日期,Vehicle_id,车辆制造,车辆型号,车辆年份}开始,标准化将表示Service_ID - > Vehicle_ID,Vehicle_ID - >车辆制造,车辆型号和车辆年。 That's a transitive dependency. 这是一种传递依赖。 To fix that transitive dependency, 要修复这种传递依赖,

  • those four columns would be projected, forming a new relation (your Vehicles table), 这四列将被投射,形成一个新的关系(你的车辆表),
  • vehicle make, vehicle model, and vehicle year would be removed from the starting relation, leaving it with 3 fewer attributes than it started with. 车辆制造,车辆模型和车辆年份将从起始关系中移除 ,使其比起始时少3个属性。

And there's still a vehicle id in the service relation. 并且在服务关系中仍然存在车辆ID。

So your teacher has given you an assignment that does not require you to normalize. 所以,你的老师给你, 不需要你一定要规范分配。 It requires you to identify where someone else screwed up the normalization, and fix it. 它需要您确定其他人搞砸了规范化并修复它的位置。 Nothing wrong with that kind of assignment, but there's a lot wrong with calling it normalization. 这种赋值没有错,但是将它称为规范化有很多错误。 (IMHO) (恕我直言)

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

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