I’m designing a database for an online checkout as a project. This is the first database I’ve made so go easy on me.
Anyways, I have tables “account”, “order”, “shopping cart” and “sku”. Account holds the shipping info, name, phone, email, etc. The primary key is accountNumber. Order holds the billing information. It’s foreign key is accountNumber and it’s primary key is OrderID. Shopping Cart only has 2 columns-orderID and skuNumber. OrderID is the foreign key and skuNumber is the primary key. SKU has 4 columns-skuNumber, quanity, price, unit, and totalPrice. skuNumber is foreign and primary key.
My question is- the way I currently have this setup only 1 item sku can be ordered at a time. How would you design this differently so that wasn’t necessary? I know I could do sku1, sku2, etc., but that seems like it would be against best practices.
Thanks!
Your database isn’t normaized by this design, instead of the
SKUtable you will need two extra tables, becouse you simply need to separate the prodcts details(Name,price, etc…) from the Order details, so you will have to add the following tables:Products:
Id.Name.Price.Another one
OrderItemsorSKUItemsthat contains the following columns:OrderIDforeign key to the orders table.ProductIda foreign key to the products table.Quantity.I didn’t understand what
SKUis but if it is some kind of product type, you can add an extra tableProductTypes: Id, namethat holds product types, this table contains for example a product type calledSKUthen you can add aProductTypeIdto yourProducts, so you could have something like:For the
Productstable: