Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > General > Database Concepts & Design > split a big table to few smaller tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-08, 18:21
lmei007 lmei007 is offline
Registered User
 
Join Date: Jun 2008
Posts: 18
split a big table to few smaller tables

I have a customer table which has lots of infomation (bank, expense, income, address, properties, ....). It is too big in my view. So I decided to split it into few smaller tables: customer, expense, income, address.

1. my decision is good or not?
2. the customer table has a custId as its primary key. For all other smaller tables, I can use the custId as its primary key, or I can declare a different primary key for those smaller tables and use the custId as their foreign key. Which way is better?

thank you guys.
Reply With Quote
  #2 (permalink)  
Old 06-05-08, 18:57
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
1. not
2. custId should be PK
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #3 (permalink)  
Old 06-06-08, 10:17
lmei007 lmei007 is offline
Registered User
 
Join Date: Jun 2008
Posts: 18
Quote:
Originally Posted by r937
1. not

Why is not good? because there will be join queries? That means the size of a table does not matter as long as those columns are needed?

Does that also mean we should join all tables together if those tables only have a simple one-to-one relationship?

thanks,
Reply With Quote
  #4 (permalink)  
Old 06-06-08, 10:42
lmei007 lmei007 is offline
Registered User
 
Join Date: Jun 2008
Posts: 18
Quote:
Originally Posted by r937
2. custId should be PK

Should I specify the custId is a foreign key also?
Reply With Quote
  #5 (permalink)  
Old 06-06-08, 15:11
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
Quote:
Originally Posted by lmei007
Why is not good?
because breaking a table up because it's "too big" is not the same as breaking a table up because it isn't in a high enough normal form

normalize first, then run your app for a year or two, and then break it up (i.e. partition) for performance if necessary
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #6 (permalink)  
Old 06-06-08, 15:12
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,539
Quote:
Originally Posted by lmei007
Should I specify the custId is a foreign key also?
in a 1-to-1 relationship, yes, one of the tables will have a PK, and the other will have the same column as a PK/FK
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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