简体   繁体   English

对包含两列的简单表进行归一化 (3NF)

[英]Normalization (3NF) on a simple table of two columns

I have a table with only two attributes (DeliveryPerson and DeliveryTime).我有一个只有两个属性(DeliveryPerson 和 DeliveryTime)的表。 Each person can deliver a “product” at a specific Delivery Time.每个人都可以在特定的交付时间交付“产品”。 As you can see below John for example has delivered three products at different delivery times.正如您在下面看到的,John 例如在不同的交货时间交付了三种产品。

在此处输入图像描述

According to my task, I must put this table in 3NF, but I am confused because I cannot set “deliveryPerson” as a primary key because there are repeated values in this column.根据我的任务,我必须把这张表放在 3NF 中,但我很困惑,因为我无法将“deliveryPerson”设置为主键,因为该列中有重复的值。 Is there any way of setting up this table to satisfy 3NF?有没有办法设置这个表来满足 3NF? If that is not possible, is it correct to have a table like this in a DB without a Primary key?如果这是不可能的,那么在没有主键的数据库中拥有这样的表是否正确?

Thank you very much!非常感谢!

Normalisation is not about adding Primary Keys to a table where you've already decided the columns, it's about deciding what tables and columns you need in the first place.规范化不是将主键添加到您已经确定列的表中,而是首先确定您需要哪些表和列。 The inability to define a Primary Key on this table is the problem you've been asked to solve;无法在此表上定义主键是您被要求解决的问题; the solution will involve creating new tables.该解决方案将涉及创建新表。

Rather than looking at the table, look at the data you're trying to model:与其查看表格,不如查看您尝试 model 的数据:

  • There are four (and probably any number of) delivery people有四个(可能是任意数量)送货员
  • Each delivery person can have one or more (maybe even zero) delivery times每个送货员可以有一个或多个(甚至可能为零)送货时间

A normalised database will represent each of those separately.规范化的数据库将分别表示其中的每一个。 I'll leave the details for you to work out, rather than feeding you the full answer.我会把细节留给你去解决,而不是给你完整的答案。

There are plenty of tutorials available which will probably explain it better than me.有很多可用的教程可能会比我更好地解释它。

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

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