If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > To have a separate table for optional items?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-04, 22:35
roman2 roman2 is offline
Registered User
 
Join Date: Aug 2004
Posts: 17
To have a separate table for optional items?

I have a database design question. Let's say I have a table with a list of people. Each person can have a number of associated items. The items are optional but their maximum number is predetermined.

Theory of database design recommends having a separate table with those items, in which each item is related to its owner (a person) by a key. I think this is a good idea if the number of items is unknown. But if the max number of them is preset and is rather small (say, 5), is it more efficient to have 5 attributes for the optional items added to the main table? I think accessing all data items pertaining to a particular record would be faster in this case. There MAY be some space wasted, but do modern DBMSs preallocate space and leave it empty until optional items are assigned value?

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 08-11-04, 05:35
jwab jwab is offline
Registered User
 
Join Date: Jul 2004
Location: UK
Posts: 43
This one relates to a super/sub type thread we had going.
The vetrens were saying stick with the one table, have null values's isnt such a hit in your case, plus only 5 fields wont pup much strain on the DBMS. Querying would be alot easier in the single table deisgn..

If people could be placed into subtypes, ie there are only a set number of combinations of people n' items, then you might have an argument to support tabling them off (purist view) otherwise go with whats easy.
Reply With Quote
  #3 (permalink)  
Old 08-11-04, 14:15
roman2 roman2 is offline
Registered User
 
Join Date: Aug 2004
Posts: 17
Are you referring to thread titled "RE: Boring" (http://www.dbforums.com/t1004407.html)? I'd like to read it.
Reply With Quote
  #4 (permalink)  
Old 08-13-04, 05:22
jwab jwab is offline
Registered User
 
Join Date: Jul 2004
Location: UK
Posts: 43
Yes that is the thread I'm referring to.
Reply With Quote
  #5 (permalink)  
Old 08-13-04, 07:04
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
roman2, don't worry about the wasted space for NULLs, it is minimal

jwab, that was a gorgeous thread, wasn't it? it made me think!

as for "items are optional but their maximum number is predetermined" be careful and ensure that they are all different, otherwise it might be better, if they are the same, to have a real one-to-many relationship

example: persons table, one row per person --

id, name, etc, homephoneno, cellphoneno, faxphoneno, ...

there was a thread about phone numbers, too
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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

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