BCNF是比第三范式更严格一个范式。它要求关系模型中所有的属性(包括主属性和非主属性)都不传递依赖于任何候选关键字。也就是说,当关系型表中功能上互相依赖的那些列的每一列都是一个候选关键字时候,该满足BCNF。

BCNF实际上是在第三范式的基础上,进一步消除了主属性的传递依赖。

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

一次Lab的作业题目如下:

A luxury car-rental company has been tracking their rental data in a simple spreadsheet, but now wants to migrate to a proper database. Consider the table given below, containing some sample data.

BCNF范式及其分解方法(对一次Lab作业的总结) Mysql 第1张

 (a) Identify at least 10 functional dependencies (non-trivial with minimal LHS) that hold on the table above.

(b) Classify the functional dependencies found as either ‘sensible’ or ‘accidental’.

给了个这个租车表,要求写函数依赖关系,这里只写sensible的,accidental的没有固定标准,不写。

依赖如下:

plate->make
make ->daily_rate
license_nr->dob
license_nr->name
plate+start_date ->*  (*表示除这两项之外的剩余部分都可以表示)

 

考虑到一个人(一个驾照可以租很多车,所以还需要租车的开始时间或者结束时间来区分)

其他的不用解释了

这里为了突出传递函数依赖,将plate,make,daily_rate分开,理解为车牌号决定厂家,厂家决定该车型每日收入,同一车型收费应该都相同,所以为互相依赖。

剩余的依赖关系都为部分函数依赖

 

建表如下:

建立4个表

table1
plate start_date end_date license_nr  (plate start_date为主键)

table 2
name dob license_nr  (license_nr为主键)

table3和table4传递关系 分开写

table 3
plate make  

table 4
make daily_rate

 

转载一篇博文,有关BCNF的分解算法的:

https://blog.csdn.net/panxiqie___/article/details/38899021

 

这里根据这个dalao写的试着分析一下自己的:

 

plate->make
make ->daily_rate
license_nr->dob
license_nr->name

plate+start_date ->*  

BCNF范式及其分解方法(对一次Lab作业的总结) Mysql 第2张

结束

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄