Lykos22 Posted July 24, 2014 Share Posted July 24, 2014 Lets take for example the following tables Posts-------------------------postID (pk)titlecategoryID (fk)etc etcProducts-----------------------productID (pk)namecategoryID (fk)etc etcFaqs---------------------faqID (pk)questioncategoryID (fk)etc etc All 3 tables contain a field categoryID, so basicle each post, product, question etc belong to a specific category. I'd like to know which is the best way to create my categories. 1. Create n-different category tables each time, such as posts_categories, products_categories, faq_categories etc etc, so basicly there all will be indipendent. 2. Create a single table for all categories with the following fields Categories--------------------categoryIDcategorytype * // values (probably set as ENUM type - from a dropdown menu): posts, products, faqs etc etc Example [table=width: 500][tr] [td]categoryID[/td] [td]category[/td] [td]type[/td][/tr][tr] [td]1[/td] [td]Science[/td] [td]posts[/td][/tr][tr] [td]2[/td] [td]Shirts[/td] [td]products[/td][/tr][tr] [td]3[/td] [td]Design[/td] [td]faqs[/td][/tr][/table]Which do you believe is the best way to organize my categories ??? Link to comment Share on other sites More sharing options...
niche Posted July 24, 2014 Share Posted July 24, 2014 I'd do it flexibly. You're bound to change it as you develop your scripts. Link to comment Share on other sites More sharing options...
Lykos22 Posted July 24, 2014 Author Share Posted July 24, 2014 Thanks for your reply. I'd do it flexibly. You're bound to change it as you develop your scripts. What do you mean? 1st way? Link to comment Share on other sites More sharing options...
niche Posted July 24, 2014 Share Posted July 24, 2014 What ever you decide, you're bound to change, so don't spend too much time deciding. Your first thought is probably good enough to get started. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 24, 2014 Share Posted July 24, 2014 The second one will be more flexible. If you can change your application without changing the database structure then the design is more flexible. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now