【问题标题】:Normalisation clarification规范化说明
【发布时间】:2015-09-22 09:11:57
【问题描述】:

大家好

我在这里遇到了一个小问题(请记住,我是新手)。原则上,我正在建立一个非常非常小的库存系统。我试图规范化我的表。我遇到了一个小问题,我将展示它,当我到达 3NF 时。 这是过程

UNF

    Product (productID, productName, productBrand, productQuantityinstock, 
            productQuantitySold, productCost, adminstaffID, adminstaffName,
             adminstaffUserName  adminstaffPassword, productcategoryID, 
            productcategoryName, { customerID, customerName,      
           customerAddress, customerContact, serviceID,
           serviceType,serviceCost, serviceStatus, 
           serviceDetails, techstaffID, tsUsername, 
           techstaffPassword } )

INF

    Product (productID, productName, productBrand, productQuantityinstock, 
            productQuantitySold, productCost, adminstaffID, adminstaffName,
            adminstaffUserName  adminstaffPassword, productcategoryID, 
            productcategoryName)


    Product_Customer (productID, customerID, customerName, customerAddress, 
                      customerContact, serviceID, serviceType,       
                       serviceCost,serviceStatus, 
                       serviceDetails, techstaffID, tsUsername, 
                      techstaffPassword)

2NF

    Product (productID, productName, productBrand, productQuantityinstock, 
             productQuantitySold, productCost, adminstaffID, adminstaffName,
             adminstaffUserName  adminstaffPassword, productcategoryID, 
             productcategoryName)

    Product_Customer (productID*, customerID*)

    Customer (customerID, customerName, customerAddress, customerContact, 
              serviceID, serviceType, serviceCost, serviceStatus,    
              serviceDetails, techstaffID, tsUsername, 
              techstaffPassword)

3NF

     Product (productID, productName, productBrand, productQuantityinstock, 
              productQuantitySold, productCost, productcategoryID*,  
              adminstaffID* ,)

     Admin Staff (adminstaffID, adminstaffName, adminstaffUserName   
                  adminstaffPassword,)

     Product Category (productcategoryID, productcategoryName,)

     Product_Customer (productID*, customerID*)

     Customer ( customerID, customerName, customerAddress, customerContact) 

     Tech Staff ( techstaffID, techstaffUsername, techstaffPassword)

     Service (serviceID, serviceType, serviceCost, serviceStatus,  
              serviceDetails, customerID*, techstaffID*)

以上是我所做的,但我被告知在 3NF 表单中,SERVICE 表中的 customerID 和 techstaffID 必须进入 CUSTOMER 表。

系统的设计使客户可能拥有一项或多项服务,而技术人员将执行一项或多项服务。所以我知道外键总是出现在关系的多方面,所以如果

客户到服务将是 1-M,服务方面有很多多样性

服务的技术人员将是 1 - M,服务方面也有很多多样性

我附上了一张我的 ERD 的图片。对于这两个外键的去向,我们将不胜感激。

link to ERD, cant post images as yet

【问题讨论】:

    标签: normalization database-normalization


    【解决方案1】:

    我被告知在 3NF 形式中 customerID 和 techstaffID 在 SERVICE 表中必须进入 CUSTOMER 表。

    不要听从这个建议。你的 3NF 没问题。服务调用将涉及客户和技术人员,因此在Service 表中将他们的 ID 作为外键是正确的。如果您遵循建议,这将意味着客户将连接到一个技术人员来处理他/她的所有服务请求。

    我的另一个建议是:为什么不将 TechStaffAdminStaff 合并到一个 Staff 表中,如下所示:

    Staff
    (
        StaffID,
        StaffFullName,
        StaffUsername,
        StaffPassword,
        StaffTypeID -- use this column to determine if a staff is tech or admin
    )
    

    【讨论】:

    • 非常感谢。我会听取你的建议并合并表格
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 2012-05-22
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多