I’m in need of help designing a schema for a custom CMS, with these tables:
- Products / Articles
- News
- Events
Every tables has got the usual stuff (only id’s and non-text fields, the text ones are in multilanguages tables)…
My problem comes from the creation of a ___CATEGORY table, every main table has a category table related
should I create two separate table for every “master” table (one for the category and one for the relations)
ProductCategory ( category_id ... )
ProductCategoryRel ( category_id , product_id )
NewsCategory ( category_id ... )
NewsCategoryRel ( category_id , news_id )
EventCategory ( category_id ... )
EventCategoryRel ( category_id , event_id )
Or should I create something united like this:
MainCategory ( category_id, type (Product/News/Event) ... )
ProductCategoryRel ( category_id , product_id )
NewsCategoryRel ( category_id , news_id )
EventCategoryRel ( category_id , event_id )
I really can’t decide, both solutions aren’t perfect…
Please note that the Products Category could have different (more) fields than the News/Events Category
If “Please note that the Products Category could have different (more) fields than the News/Events Category” then you should definitely go for the first option.
See http://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/ (“One ring to rule them all”)