I’m currently going to be developing a database that will hold lots of items and was wondering which design would be better is there was 1000’s to 10,000’s of items per category.
Database Design #1
Login Details
--------------
-userID
-Username
-Password
- ETC....
User Settings
--------------
-userID
-Setting 1
-Setting 2
-Setting 3
- ETC....
Product Category
-----------------
-ID
-Name
ALL Items
-----------
-ItemID
-Name
-Description
-Price
-Info
- ETC....
-parentCategoryID
OR
Database Design #2
Login Details
--------------
-userID
-Username
-Password
- ETC....
User Settings
--------------
-userID
-Setting 1
-Setting 2
-Setting 3
- ETC....
Product Category
-----------------
-ID
-Name
-tableName
Electronics
-------------
-ItemID
-Name
-Desc.
-Price
- ETC....
Food
-------------
-ItemID
-Name
-Desc.
-Price
- ETC....
Books
-------------
-ItemID
-Name
-Desc.
-Price
- ETC....
Apparel
-------------
-ItemID
-Name
-Desc.
-Price
- ETC....
Others
-------------
-ItemID
-Name
-Desc.
-Price
- ETC....
Option 1 would be the way to go.
If you used option 2, you would have to use different queries each time you wished to query the database about a different product type for you would be storing different product types in different tables.
Storing users is much less problematic than storing products. As prices can change over time, it would be better to remove the ‘price’ field from the ‘products’ table and store it in a different table, ‘pricelist’, whose fields would be product, price, fromdate (and possibly tilldate).