Results 1 to 7 of 7

Thread: Need help

  1. #1
    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?

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    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:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    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"
    www.LobsterShot.blogspot.com

  5. #5
    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?

  6. #6
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    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

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    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"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •