Jump to content

Create Categories for different sections


Lykos22

Recommended Posts

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

I'd do it flexibly. You're bound to change it as you develop your scripts.

Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...