Sql – Products database design for product lines, categories, manufacturers, related software, product attributes, etc

data modelingdatabase-designsqlsql server

I am redeveloping the front end and database for a medium size products database so that it can support categories/subcategories, product lines, manufacturers, supported software and product attributes. Right now there is only a products table. There will be pages for products by line, by category/subcategory, by manufacturer, by supported software (optional). Each page will have additional filtering based on the other classifications.

Categories/Subcategories (multi level)
Products and product lines can be assigned to multiple category trees. Up to 5 levels deep should be supported.

Product lines (single level)
Groups of products. Product can only be in single product line.

Manufacturers (single level)
Products and product lines can be assigned to single manufacturer.

Supported software (single level)
Certain products only work with one or more softwares, so a product/line can be assigned to none, one or more softwares.

Attribues (type / options – could be treated so each type is a category and items are children)
Products and product lines can be assigned attributes (eg – color > red / blue / green). Attributes should be able to be assigned to one or more categories.

Since all these items are basically types of subcategories, do I put them all together in a master table OR split them into separate tables for each one?

Master table idea:

ClassificationTypes (product line, category/sub, manufacturer, software, attribute would all be types)

-TypeID

-Name

Classifications

-ClassID

-TypeID

-ParentClassID

-Name

ClassificationsProductsAssociations

-ProductID

-ClassID

I would still need at least one more table to link types together (eg – to link attributes to a category) and a way to link product lines to various types.

If I go with a table for each type it can get messy quick and I will still need a way to link everything together.

Multiple table setup:

Categories

-CategoryID

-Name

-ParentCategoryID

CategoriesAssociations

-CategoryID

-ProductID

-ProductLineID ?

Attributes

-AttributeID

-Name

-ParentAttributeID (use this as the parent would be "color" and child would be "red")

AttributesAssociations

-AttributeID

-ProductID

-CategoryID (do I also need to link the category to the parent attribute?)

CompatibleSoftware

-SoftwareID

-Name

CompatibleSoftwareAssociations

-SoftwareID

-ProductID

-ProductLineID ?

Manufacturers

-ManufacturerID

-Name

ProductLines

-ProductLineID

-ManufacturerID

-Name

Products

-ProductID

-ProductLineID

-ManufacturerID

-Name

Other option for associations is to have a single associations table to link the tables above:

Master Associations

-ProductID

-ProductLineID

-ManufacturerID

-CategoryID

-SoftwareID

-AttributeID

What is the best solution?

Best Answer

Go for multiple tables, it makes the design more obvious and more extensible, in my opinion. While it may fit your solution now, further changes may be more difficult.

Related Topic