Normalization, changing it to 1nf, 2nf and 3nf -


invoice

so have put 1nf, 2nf , 3nf

prod_num    prod_label  prod_price aa-e3422qw  rotary sander   49.95 aa-e3422qw  rotary sander   49.95 qd-300932x  0.25in. drill bit   3.45 ru-95748g   band saw    33.99 gh-778345p  power drill 87.75 

ven_code   ven_name 211 neverfail, inc 211 neverfail, inc 211 neverfail, inc 309 begood, inc 157 toughgo, inc 

so far have these 2nf. going right? , how put table 3nf ?

so 2nf ?2nf table image

i think picture given considered 1nf.

and showed 3nf, you'll need additional table reference product vendor modify invoice table.

vendor - unique list of vendors

ven_id | ven_code | ven_name -------|----------|--------------- 1      | 211      | neverfail, inc 2      | 309      | begood, inc 3      | 157      | toughgo, inc 

product - unique list of products

prod_id | prod_num   | prod_label        | prod_price --------|------------|-------------------|----------- 1       | aa-e3422qw | rotary sander     | 49.95 2       | qd-300932x | 0.25in. drill bit | 3.45 3       | ru-95748g  | band saw          | 33.99 4       | gh-778345p | power drill       | 87.75 

vendor_product - mapping between products , vendors

ven_id | prod_id -------|---------- 1      | 1 1      | 2 2      | 3 3      | 4 

purchases - transactions happened

purch_id | inv_num | sale_date   | prod_id | quant_sold ---------|---------|-------------|---------|------------ 1        | 211347  | 15-jan-2006 | 1       | 1 2        | 211347  | 15-jan-2006 | 2       | 8 3        | 211347  | 15-jan-2006 | 3       | 1 4        | 211348  | 15-jan-2006 | 1       | 2 5        | 211349  | 16-jan-2006 | 4       | 1 

i think good, can split again.

invoices - unique list of invoices

inv_id  | inv_num | sale_date --------|---------|------------- 1       | 211347  | 15-jan-2006 2       | 211348  | 15-jan-2006  3       | 211349  | 16-jan-2006  

purchases - transactions happened

purch_id | inv_id | prod_id | quant_sold ---------|--------|---------|--------- 1        | 1      | 1       | 1 2        | 1      | 2       | 8 3        | 1      | 3       | 1 4        | 2      | 1       | 2 5        | 3      | 4       | 1  

to 2nf, combine vendor information product table. these columns

prod_id | prod_num | prod_label | prod_price | ven_code | ven_name 

in case, vendor , vendor_product tables aren't needed.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -