Thursday, February 16, 2012

Category tables

What are the thoughts on using a categoy table? What I mean by this is to have a table used to hold simply a category identifier for other table(s).

Eg:

Hardware Table
Hadware (PK) | Category (FK) | Description | Finish | etc...
------------------------
P1 | Plate | 4"x4"x1/4 plate | Painted |

HardwareCategories
Category (PK)
------
Plate
Channel
Angle

Should this be done or simply provide a category field in the hardware table? I like the extra table because it kind of ensures that a user doens't add a plate with a category value "Plate", another user adds "plate", and another user adds "Plates", etc...

What are your thoughts if any?

Mike BMake Category -> CategoryID, still a FK in your Hardware table (tbHardware)

Make tbCategory have:

CategoryID PK
CategoryName

If your products can have multiple categories, pull CategoryID out of tbHardware and make a new table called tbHardwareCategory

This will have:

HardwareID
CategoryID

Make sense?

No comments:

Post a Comment