Consider the price of products in the table differs in each state. If the price varies in district I also have to mention it. How can I do this for more than 5 states?
product Name Price Wholeseller Price Retailer price state district
-------------|------|------------------|---------------|-----------|------
fan | 6 | 12 | 18 | delhi name1
wheels | 10 | 17 | 27 | delhi name1
biscuits | 5 | 10 | 23 | delhi name1
biscuits | 6 | 11 | 24 | delhi name2
fan | 7 | 13 | 20 | karnataka ...
wheels | 9 | 16 | 26 | karnataka ...
biscuits | 5 | 12 | 25 | karnataka ...
Image of table here.
Here I'm repeating the product for each state. Is it a correct method? Should I make a separate table for states & districts or is there a need to normalize?
Best Answer
You should normalize your tables. In third normal form (3NF) you tables would look like this:
Notice that this is different from your normalized table picture in two important respects: First, states and districts should be separated into two tables so you don't repeat the state names. Second, and more importantly, prices depend on district and product. Therefore the price should be in the intersection table between district and product, not in the same table as states and districts.