Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
What is the correct way create two similar tables?
Old
  (#1)
Guest
Guest
 
Posts: n/a
Default What is the correct way create two similar tables? - 06-04-2007, 07:48 AM

Hey,

I will be creating two tables with similar data. However I was
wondering what the standard is for this.

Should you

a) Create two tables eg
CREATE TABLE foo (id TINYINT UNSIGNED NOT NULL, name char(20) NOT
NULL);
CREATE TABLE footwo (id TINYINT UNSIGNED NOT NULL, name char(20) NOT
NULL);


b) Create one table with a column variable "type" to differentiate.
CREATE TABLE foo (id TINYINT UNSIGNED NOT NULL, name char(20) NOT NULL,
type char(20) NOT NULL);

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: What is the correct way create two similar tables?
Old
  (#2)
AlterEgo
Guest
 
Posts: n/a
Default Re: What is the correct way create two similar tables? - 06-04-2007, 07:48 AM

Blaine,

Both are correct. The question might be: Which would better meet my
requirements? Usage, data volume and maintainability all have implications.
The larget the number of rows, the better the arguement for two tables.

If you have one table and you are querying based upon type, then you might
want an index on the type column.

-- Bill


<EMAIL REMOVED> wrote in message
news:EMAIL REMOVED ups.com...
> Hey,
>
> I will be creating two tables with similar data. However I was
> wondering what the standard is for this.
>
> Should you
>
> a) Create two tables eg
> CREATE TABLE foo (id TINYINT UNSIGNED NOT NULL, name char(20) NOT
> NULL);
> CREATE TABLE footwo (id TINYINT UNSIGNED NOT NULL, name char(20) NOT
> NULL);
>
>
> b) Create one table with a column variable "type" to differentiate.
> CREATE TABLE foo (id TINYINT UNSIGNED NOT NULL, name char(20) NOT NULL,
> type char(20) NOT NULL);
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top