My original table which is not normalised looked like this:[1]: https://i.stack.imgur.com/NbKV4.png
Now after following the conditions of each form, I managed to separate the table into 3 forms which look like this[2]: https://i.stack.imgur.com/b414X.png [3]: https://i.stack.imgur.com/haz2Q.png [4]: https://i.stack.imgur.com/CpWXw.png
My aim is to make the database into 3NF, is this the case? If not, please give me some advice on any amendments needed, thanks.
You went from
(product_id, product_name, product_cat, product_subcat, cost, stock)
to
products_details(product_id, product_name, stock)
products_categories(product_cat, product_subcat)
products_costs(cost_id, cost)
That's good but not enough according to me. And not complete either. Here's a first solution…
product_details(product_id*, psub_id@, product_name, cost, stock)
product_categories(pcat_id*, pcat_name)
product_subcategories(psub_id*, pcat_id@, psub_name)
…where *
indicates the primary key, and @
the foreign key. Another possible second solution is
product_details(product_id*, pcat_id@, product_name, cost, stock)
product_categorisation(pcat_id*, pcat_parent@, pcat_name)
This later is good only when not all categories have subcateries (not sure my writing is clear here, sorry.)
Also note that I didn't put costs in a table by their own because I don't think they are such independant. However, I don't know the context you are modeling.
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.