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 > Need help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-23-09, 07:37
davidgale davidgale is offline
Registered User
 
Join Date: Apr 2009
Posts: 2
Need help

I have a table Persons with columns ID, NAME and SEX. The problem is that in my db i also have to represent different details for male and female persons. Therefore i have two tables named MaleDetails and FemaleDetails with columns ID, Detail1, Detail2, Detail3 etc. What is the best way to create Master-Detail relationship between the tables Persons, MaleDetails, FemaleDetails?
Reply With Quote
  #2 (permalink)  
Old 04-23-09, 07:40
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Google "sub type super type".

As a follow up, I'm dying to know what male & female specific details you keep, and do you need someone to help verify (half of) them?
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 04-23-09, 07:43
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #4 (permalink)  
Old 04-23-09, 09:13
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Unless there are an enormous number of attributes you need to track that are exclusive to one gender, just put them all in one table and accept that some will have NULL values.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #5 (permalink)  
Old 04-25-09, 17:15
davidgale davidgale is offline
Registered User
 
Join Date: Apr 2009
Posts: 2
ok. i understand the concept. however look at this table: http://msdn.microsoft.com/en-us/libr...us,SQL.80).gif. the database design does not forbid you to put an id of a vehicle the type of which is set to car into the table Trucks. is this a good way to design a db?
Reply With Quote
  #6 (permalink)  
Old 04-25-09, 17:32
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
Quote:
Originally Posted by davidgale
ok. i understand the concept. however look at this table: http://msdn.microsoft.com/en-us/libr...us,SQL.80).gif. the database design does not forbid you to put an id of a vehicle the type of which is set to car into the table Trucks. is this a good way to design a db?
David Portas' Blog : Distributed Keys and Disjoint Subtypes
Reply With Quote
  #7 (permalink)  
Old 04-27-09, 10:38
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Quote:
Originally Posted by davidgale
ok. i understand the concept. however look at this table: http://msdn.microsoft.com/en-us/libr...us,SQL.80).gif. the database design does not forbid you to put an id of a vehicle the type of which is set to car into the table Trucks. is this a good way to design a db?
This can be enforced with either composite foreign keys or indexed views. But again, I'd just put it all in one table if possible.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
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