To split a table or not to

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

To split a table or not to

Post by GeXus »

I have one table called "content" and within that there is main content and description content. Because im keeping a history of all of the content and description content with date stamps asigned to each, I will have a lot of empty columns for one or the other, meaning there will never be content and description content in the same row. Would it be benificial to split this into two tables, even though they are all somewhat related?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I cant see anything wrong either way, but splitting it up would make it more organized if you have empty columns. Empty columns are a waste. :wink:
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: To split a table or not to

Post by califdon »

GeXus wrote:I have one table called "content" and within that there is main content and description content. Because im keeping a history of all of the content and description content with date stamps asigned to each, I will have a lot of empty columns for one or the other, meaning there will never be content and description content in the same row. Would it be benificial to split this into two tables, even though they are all somewhat related?
As an old database instructor, I'll say that there is one and only one criterion for what columns should be in a table: all columns that contain attributes of the entity represented by a table. Now, what does that mean? It's hard to know whether "content" is an entity because you haven't given enough information to judge that. What does the table really represent? What distinguishes one piece of content from another? How are you going to index it? My first impression would be that content is content, and I'd suggest perhaps a single table with a single "content" column, a datestamp column, and a "type" column that could be of type enum, having two values: either "main" or "description".
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Re: To split a table or not to

Post by GeXus »

Califdon, Thanks a lot.. that would work perfect.
califdon wrote:
GeXus wrote:I have one table called "content" and within that there is main content and description content. Because im keeping a history of all of the content and description content with date stamps asigned to each, I will have a lot of empty columns for one or the other, meaning there will never be content and description content in the same row. Would it be benificial to split this into two tables, even though they are all somewhat related?
As an old database instructor, I'll say that there is one and only one criterion for what columns should be in a table: all columns that contain attributes of the entity represented by a table. Now, what does that mean? It's hard to know whether "content" is an entity because you haven't given enough information to judge that. What does the table really represent? What distinguishes one piece of content from another? How are you going to index it? My first impression would be that content is content, and I'd suggest perhaps a single table with a single "content" column, a datestamp column, and a "type" column that could be of type enum, having two values: either "main" or "description".
Post Reply