简体   繁体   中英

What normal form is this model in and why?

I'm having trouble understanding normalisation could someone please explain what Normal Form this relational model is in and why?

Customers ( customerID (PK), firstName, lastName, streetNo, street, suburb, postCode, state, phoneNumber,emailAddress, orderID (FK))

Orders ( orderID (PK), orderDateTime, paymentStatus, productQuantity, productID (FK))

Product ( productID (PK), productName, productDescription, currentUnitPrice, inStock, status, categoryID, categoryName)

SalesPerson ( salesPersonID (PK), firstName, lastName, email, phoneNumber, supervisorID (FK), orderID (FK))

OrderContents ( orderContentsID (PK), date, discount, streetNo, street, suburb, postcode, state, paymentStatus)

Partner (partnerID (PK), companyName, streetNo, street, suburb, postcode, state, lastName, firstName, phoneNumber, email, orderContentsID (FK), salesPersonID(FK))

I would argue that your schema is not 2NF, and therefore is 1NF. In order for a table to be 2NF, there must not be any partial dependency of a column on the primary key. Consider your Customers table. You have labelled the customerID the primary key, but in reality this won't work, because a given customer may have more than one order. Actually, the primary key is the combination (customerID, orderID) . But then this creates the problem that the customer address columns, eg postCode , are dependent on the composite primary key. To be specific, there may be several records where the same customer address information appears, and this is redundant.

To make your schema 2NF (at least a portion of it), you can create a new table CustomerOrders which stores only the relationships between customers and their orders, and nothing else:

CustomersOrders(customerID, orderID) (PK)

Then, refactor your Customers table by removing the order ID:

Customers (customerID (PK), firstName, lastName, streetNo, street, suburb, postCode,
           state, phoneNumber,emailAddress)

So, I believe your schema as it currently stands is 1NF, but you might be able to bring it to 2NF with a little work.

Here is a reference on 2NF which an example very similar to your schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM