I am trying to understand database normalization, in particular 3NF.
I am building a shop database and in trying to normalize to 3NF have come up with the structure below.
The structure below assumes
- There may be multiple categories per product
- There is only ever one storage_location & manufacturer per product
- There may be unlimited extra_fields
Can anybody tell me if I am on the right track, is the below structure in 3NF, or close?
Products
----------------
pid (pk)
title
desc
price
weight_base
weight_additional
note
quantity
manufacturer_id (fk)
storage_location_id (fk)
Categories
-----------------
category_id (pk)
category_name
parent_id
description
Product_categories
-----------------
pid (pk)
category_id (pk)
Manufacturers
-------------------
manufacturer_id (pk)
name
description
Storage_locations
---------------------
storage_location_id (pk)
storage_ref
storage_note
Product_extra_field_values
-----------------------------------
PID (pk)
extra_id (fk)
value
Product_extra_fields
--------------------------------
extra_id (pk)
label
Two main things I am unsure about:
Is it correct to use a composite key for Product_categories to accommodate for multiple identical PIDs in the table?
Is it correct to simply add a foreign key to the primary Products table for manufacturer and storage_location because they will only occur once per product record? Or should specific manufacturer and storage_location id be removed from primary Products table and new tables be created like this:
Product_storage_locations ---------------------------------- PID (pk) storage_location_id (pk)