Hopwin wrote:
So how would you go about it?
Page_Table
ID PageName Address Description
Category_Table
ID Category
SubCategory_Table
ID SubCategory
Topic_Table
ID Topic
Yes.
Hopwin wrote:
Then have a table of all combos?
PageID CategoryID SubCategoryID TopicID
No. The normalized option would be a PageCategories table, a PageSubCategories table, and a PageTopic table, since each categorization entity has a many to many relationship to Pages, but no relationship to its siblings.
...
...
If you wanted to denormalize that a bit, you could get rid of the Categories, SubCategories, and Topic tables, and just create one master table ("Groups" because I'm bad at naming - I'm sure you can come up with a better one):
Code:
GroupID int (your PK)
GroupTypeID int FK to GroupTypes table
GroupName varchar(50)
GroupTypes
GroupTypeID int
GroupTypeName varchar(50)
GroupTypes sample data:
GroupTypeID 1 Category
GroupTypeID 2 SubCategory
GroupTypeID 3 Topic
So this way all your categories, subcategories, and topics would be in the same table, since they all pretty much do the same thing and share the same columns.
Group Table Sample data:
Code:
GroupID 1
GroupTypeID 1
GroupName Acceptable
GroupID 2
GroupTypeID 1
GroupName Unacceptable
GroupID 3
GroupTypeID 2
GroupName New Business
GroupID 4
GroupTypeID 2
GroupName Endorsement
GroupID 5
GroupTypeID 3
GroupName Pricing
GroupID 6
GroupTypeID 3
GroupName State Reporting
GroupID 7
GroupTypeID 3
GroupName Add a vehicle
GroupID 8
GroupTypeID 3
GroupName Point of Sale
Then just create the one bridge table to establish the many-to-many relationship, PageGroups:
Code:
PageGroupID int
PageID int
GroupID int
Depending on your real data, this could either make things more confusing or less confusing. It'd still perform decently, and would be readable. If you never expect categories, subcategories, and topics to grow by an order of magnitude, or change in complexity, this might be a way to go. If you expect to add attributes to only one type of grouping but not another (add a CategoryCode but not SubcategoryCode or something), then go with the first option (three entity tables, three bridge tables).