尝试标准化为 BCNF
我不确定这是否在BCNF中,但老师告诉我INSTRUMENT在BCNF中。他是在逗我吗?老师总是让我分不清是非,让我不确定。他一直在说一些我已经想得很清楚的事情,但我什至不明白他在说什么。
INSTRUMENT(InstrumentID、
InstrumentType、调音、表演者、Adr、电话、可用性) 注释(TitleNr,Tune,
作曲家、副本、标题、表演者)
那么这是标准化的吗?在 BCNF 中:
乐器(InstrumentID
、InstrumentType、Tune、可用性、PerformerID*)
注释(TitleNr、标题、
曲调、作曲家、副本、表演者 ID*)
PERFORMER(PerformerID
、姓名、地址、电话)
Tune 位于 INSTRUMENT 和 Notes 中。两者都可以吗?
I am not sure if this is in BCNF or not, but the teacher told me that INSTRUMENT is in BCNF.. Is he messing with me? The teacher keeps messing up my mind on what is right and wrong and making me unsure. He keeps saying stuff that i've already thought of as clearly and I don't even get what he is saying.
INSTRUMENT(InstrumentID,
InstrumentType, Tune, Performer, Adr, Phone, Availability)
NOTES(TitleNr,Tune,
Composer, Copies, Title, Performer)
So is this normalized? in BCNF:
Instrument(InstrumentID
, InstrumentType, Tune, Availability, PerformerID*)
NOTES(TitleNr, Title,
Tune, Composer, Copies, PerformerID*)
PERFORMER(PerformerID
, Name, Adr, Phone)
Tune is in both INSTRUMENT and NOTES. Can it be in both?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
每个范式都需要其前面的范式。
1 NF - 您的表只有原子值,即没有集合。
2 NF - 非密钥属性要求确定密钥的每个部分。
3 NF - 非关键属性除了要确定的关键之外不需要任何其他内容。
3.5 NF - 如果非键属性可以确定键属性,则它们必须创建唯一的元组。
我首先关心的是 TitleNr 代表什么。如果它是唯一 ID,则它不是 2 NF,因为非关键属性不需要确定标题。
我的第二个问题是,如果包含 Tune,则 InstrumentID 不是正确的候选键。如果 Instrument.Tune 代表该特定乐器演奏过的乐曲,则一台乐器可以演奏多首乐曲。最好将这些属性拆分到另一个表中,否则其他非关键属性将使其不是 2 NF。
如果它仅仅代表可用的曲调,那么它已经可以由 PerformerID 确定,而 PerformerID 不是乐器密钥的一部分。那么就不是3NF了。
Each normal form requires the normal form preceding it.
1 NF - Your table only has atomic values i.e. no sets.
2 NF - Non-key attributes require every part of your key to be determined.
3 NF - Non-key attributes do not require anything but the key to be determined.
3.5 NF - If a non-key attribute can determine a key attribute, they must create a unique tuple.
My first concern is what TitleNr stands for. If it is a unique ID then it isn't 2 NF, since the non-key attributes don't require Title to be determined.
My second concern is that InstrumentID is not a proper candidate key if Tune is included. One instrument can play multiple Tunes, if Instrument.Tune represents what tunes have been played with that specific instrument. It would be better to split those attributes out into another table, otherwise the other non-key attributes will make it not be 2 NF.
If it merely represents what Tunes are available, that can already be determined by the PerformerID, which isn't part of Instrument's key. Then it is not 3 NF.
标准化适用于单个表;它基于功能依赖性。
函数依赖性由数据决定,而不是由列名决定。你的老师没有给你任何数据。尝试仅通过列名称确定功能依赖关系是有风险的事情,即使列命名得很好。你的专栏命名不好。
富有想象力的数据库设计者可能会为演示 BCNF 的第一个“Instruments”表提出谓词和示例数据。
也许你的导师也不懂这些东西。不会是第一个。
Normalization applies to individual tables; it's based on functional dependencies.
Functional dependencies are determined by data, not by column names. Your instructor didn't give you any data. Trying to determine functional dependencies by column names alone is risky business, even when the columns are named well. Your columns aren't named well.
An imaginative database designer could probably come up with a predicate and sample data for the first "Instruments" table that demonstrates BCNF.
Maybe your instructor doesn't understand this stuff either. Wouldn't be the first.
它是 2NF,而不是 BCNF。
您确实需要了解功能依赖性,但猜测一下,我会说
adr
和phone
是表演者的属性,而不是乐器的属性。如果属性没有(完整地)描述密钥,那么它就不是 BCNF。假设每位表演者至多有一个电话号码和地址。如果是这样,您将具有功能依赖性:
也就是说,可能有多个乐器与同一表演者关联,但在每种情况下,他们的电话和地址都是相同的(因此被冗余记录)。
我猜测乐器关系的关键是
InstrumentId
,因此还有一个 FD 表示每个乐器最多关联一个表演者;既然如此,属性
phone
和adr
并不直接依赖于InstrumentId
,而是通过Performer
间接依赖。因此,在这种关系中,FD表演者-> phone, adr
是一个传递依赖。根据定义,任何包含传递依赖关系的关系都不能高于 2NF(第二范式)。所以它不属于 3NF,也不属于 BCNF。2NF 不允许部分依赖。好消息是,由于键只是一个属性,因此您不必担心此处的部分依赖关系:您不能拥有单个属性的一部分。
It's in 2NF, not BCNF.
You really need to know the functional dependencies, but taking a guess I'd say the
adr
andphone
are attributes of the performer, not the instrument. If attributes don't describe the key (in its entirety) then it's not BCNF.Assume each performer has at most one phone number and address. If so, you would have the functional dependency:
That is, there could be multiple instruments associated with the same performer, but in each case their phone and address would be the same (hence recorded redundantly).
I'll guess that the key for the Instrument relation is
InstrumentId
, so there's also a FD saying at most one performer is associated with each instrument;That being the case, attributes
phone
andadr
don't depend directly uponInstrumentId
, but indirectly viaPerformer
. Hence within this relation the FDPerformer -> phone, adr
is a transitive dependency. Any relation containing transitive dependencies by definition cannot be in anything higher than 2NF (second normal form). So it's not in 3NF, nor BCNF.2NF doesn't allow partial dependencies. The good news is that since the key is only one attribute you don't have to worry about partial dependencies here: you can't have part of a single attribute.