Let's say I'm keeping a shipping record of products I sell.
Product | Type | Year Made | Item Cost | Shipping Cost | Total Cost | Sold to | Sale Date |
--------+------+-----------+-----------+---------------+------------+---------+------------
Ford 30 | Car | 1962 | 1000 | 500 | 1500 | Bob | 01/22/123 |
BOXXXXX | Box | 1223 | 5 | 10 | 15 | Sam | 03/44/321 |
How do I normalize the last 3 columns? Also, am I missing any thing in achieving 3NF?
Supposing that there are no constraints on Item Cost
and Total Cost
(in particular, that they may be both individually and pairwise duplicated in different rows) the pair do not form a superkey of the table. The table therefore cannot be in third normal form if it contains any other column that is functionally dependent on that pair alone.
If Total Cost
is expected always to be equal to Item Cost
+ Shipping Cost
, that constitutes a functional dependency on Item Cost
and Shipping Cost
, which means the table is not in 3NF. You can convert your table to 3NF by dropping the Total Cost
column. Your clue here might be that dropping the column would not lose any data.
If you postulated a computing system that could not perform arithmetic (or a relationship that was not directly calculable) then instead of dropping Total Cost
altogether, you could move it to a separate table having columns (Item Cost
, Shipping Cost
, Total Cost
). That seems pretty silly for this particular case, though.
I don't see any normalization issues with the Sold to
and Sale Date
columns. As far as I can tell, each depends exclusively on the Product
column, which I take as the the sole member of the only candidate key of the table.