【问题标题】:in normalization, how to tell if this is in first second or third normal form (1nf,2nf,3nf)在规范化中,如何判断这是第一第二或第三范式(1nf,2nf,3nf)
【发布时间】:2017-01-18 07:10:27
【问题描述】:

这是课堂上的一个例子,在大多数情况下,我可以将它们转换为 1NF、2NF 和 3NF。我不明白的是这个问题最初是什么形式的。教练没有解释它,据我了解,最初的速记符号根本不会是任何规范化的形式。我正在检查的速记符号是粗体的。我遇到的问题也是粗体字。

员工(employeeID,employeeName, salesOffice, officePhone, (customerID, name, address, city, state, zip))

函数依赖

employeeId → employeeName, salesOffice, officePhone

salesOffice → officePhone

customerID → name, address, city, state, zip

zip → state, city

它目前是什么正常形式?如果不在 3NF 中,则显示 1NF、2NF 和 3NF

1NF

Staff(employeeID,employeeName, salesOffice, officePhone, customerID, name, address, city, state, zip)

2NF

Staff(employeeID,employeeName, salesOffice, officePhone) 

customer(customerID, name, address, city, state, zip) 

saleCust(employeeID, customerID)

3NF

Staff(employeeID,employeeName, salesOffice, officePhone) 

customer(customerID, name, address,zip) 

saleCust(employeeID, customerID) 

zip(city, state,
zip)

我是否正确地说提供的初始速记形式(粗体)根本不是标准化形式?

【问题讨论】:

    标签: database forms relational-database normalization


    【解决方案1】:

    是的,这样说是完全正确的。你不必只是说出来。你也有事实要证明。

    你可以写:

    正如 1NF 所述:

    表必须具有所有原子值。

    Staff(employeeID,employeeName, salesOffice, officePhone, (customerID, name, address, city, state, zip))
    

    在上面的员工表中,客户信息不是原子的,所以它不在1NF中。

    1NF 中的解决方案:

    Staff(employeeID,employeeName, salesOffice, officePhone, customerID, name, address, city, state, zip)
    

    然后是 2NF 声明:

    您的表中不应存在任何部分依赖,或者每个非键属性必须完全依赖于键属性值。

    Staff(employeeID,employeeName, salesOffice, officePhone, customerID, name, address, city, state, zip)
    

    在上述关系中,employeeNamesalesOfficeofficePhone 依赖于 employeeIDaddress , city, state, zip on CustomerID

    2NF 中的解决方案:

    Staff(employeeID,employeeName, salesOffice, officePhone) 
    
    customer(customerID, name, address, city, state, zip) 
    
    saleCust(employeeID, customerID)
    

    最后,3NF 出现:

    表中不应有任何传递依赖。

    Staff(employeeID,employeeName, salesOffice, officePhone) 
    
    customer(customerID, name, address, city, state, zip) 
    
    saleCust(employeeID, customerID)
    

    现在从上面的关系来看,statecity 依赖于 zipzip 反过来又依赖于 客户ID

    3NF 中的解决方案:

    Staff(employeeID,employeeName, salesOffice, officePhone) 
    
    customer(customerID, name, address,zip) 
    
    saleCust(employeeID, customerID) 
    
    zip(city, state,
    zip)
    

    通过这种方式,您不仅可以说而且还可以证明该问题甚至不在1NF中。

    【讨论】:

    • 谢谢你,我只是感到困惑,因为我的导师让它看起来是它最初应该是某种规范化的形式。我只是想验证它实际上不是任何标准化形式,非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2014-12-14
    • 2021-11-21
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    相关资源
    最近更新 更多