【发布时间】: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 的图片。对于这两个外键的去向,我们将不胜感激。
【问题讨论】:
标签: normalization database-normalization