is there a good idea to store all the data in one table for many categories or for one category one table?

They have: 2 posts

Joined: Mar 2010

is there a good idea to store all the data in one table for many categories or for one category one table? please help me
thanks

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Without knowing the specifics of what type of data you are saving, I would say if all the data contained the same fields, and were all related just grouped by the category, then one table for the data, and then depending on the number of categories, the use, and chances of adding to the list in the future, either and ENUM field listing the categories or table of data and a table of categories, with the data table having a key over ot the category table (preferable as a foreign key relation).

Again, this is generalized not knowing what type of data and what it is used for.

-Greg

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Agreed with Greg. You should have one table for ‘data’ (whatever that might be) and another table for
categories linked by ‘categoryid’, do not create separate tables for each category though, that's evil. Wink

It might be possible -- and a good idea for performance and the integrity of your data -- to split the data out into further tables, however we'd need to know specifics of what you're doing to advise on that.

Oh and welcome to TWF! Smiling

a Padded Cell our articles site!

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Reading this again, and your other post: http://www.webmaster-forums.net/web-database-development/database-design... and assuming they're related.

You're probably better off using a CMS, like Drupal or, if your needs are simple, blogging software Wordpress can be really good for small sites.

a Padded Cell our articles site!

He has: 53 posts

Joined: Jun 2010

According to me that's not good, & it's create an situation against Normalization Concept, which means that, normalization is the process through which we organize tables in such a way that the results contain no duplicate data , but we get the data in more consistence form. or in other word we can say that it is the process of braking down one table into it's sub tables so that data redundancy can be removed.

Example:
Customer Item - purchased - Purchase price
Sandeep - Shirt - 940
Deepak - Tennis shoes - 2300
Krishna - Trousers - 550

Now here we store all the data in one table for many categories
then what happen ??? Suppose you delete one of the customers sandeep, that's OK but you see, you also delete the price of shirt, Now how we overcome that, through Normalization, here we dividing this table into two tables,

1)customer and a product
Customer Item - purchased
Sandeep - Shirt
Deeapk - Tennis shoes
Krishna - Trousers

2)product and its price. purchased- Purchase price
Shirt - 940
Tennis shoes - 2300
Trousers - 550

then we solve my Bad Situation. and Now I think that you get it my all point that's I want to share with you.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.