Data Modeling Question - Page 2
DBAsupport.com Forums - Powered by vBulletin
Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Data Modeling Question

  1. #11
    Join Date
    Jul 2008
    Posts
    8
    Quote Originally Posted by citldba
    So Bob - is it just me and you again then ?
    No, PAVB is busy trying to boost his ego by criticizing me...

    Anyone that has anything constructive to add is welcome to join in!

    citldba, I have had a few other people say that using a Super-Type/Sub-Type approach would be reasonable and is a good way to avoid having a "wide" table with lots of Nulls.

    I also think it encourages keeping "Apples with Apples" and "Unleaded with Unleaded"!!

    Attached is an ERD I created yesterday. It is far from complete, and does not show everything, but is a good sample of what - I believe - we were discussing...



    Just Bob
    Attached Images Attached Images

  2. #12
    Join Date
    Feb 2004
    Location
    UK
    Posts
    56
    Yes, that looks like the sort of thing we have been talking about

  3. #13
    Join Date
    Jul 2008
    Posts
    8
    Quote Originally Posted by citldba
    Yes, that looks like the sort of thing we have been talking about
    Okay, good!

    Is there a need for each Sub-Type Table (e.g. Telephone) to have its own PK (e.g. "TelephoneID") plus a FK (e.g. "ExpenseID") to link back to the Super-Type Table (i.e. Expense), or is it okay to just have one ID field that is both a PK and FK?


    Just Bob

  4. #14
    Join Date
    Feb 2004
    Location
    UK
    Posts
    56
    I'm not quite sure what you mean. If you don't have a sub-type id (e.g TelephoneID) then you are restricted to 1 record in each sub table per super type record (so only 1 Telephone record per expense).

    If that is what you want then you don't need to sub-type keys

  5. #15
    Join Date
    Jul 2008
    Posts
    8
    No, you didn't understand me.

    This is what I meant...

    Fuel (sub-type)
    ------------------
    ID (FK)
    FuelType
    CostPerGallon
    TotalGallons

    or...

    Fuel (sub-type)
    ------------------
    FuelID (PK)
    ID (FK)
    FuelType
    CostPerGallon
    TotalGallons

    In the 2nd example, does having a "FuelID" (PK) add any additional value for a Sub-Type table? (Obviously you want a true PK for a "regular" table.

    Oh, and I think I have actually seen a third way...

    Fuel (sub-type)
    ------------------
    FuelID (PK)
    ID (PK)(FK)
    FuelType
    CostPerGallon
    TotalGallons

    where you create a composite PK. Again, does this provide value?



    Just Bob

  6. #16
    Join Date
    Feb 2004
    Location
    UK
    Posts
    56
    I think as long as you only need one sub-type for each expense then option 1 is probably simpler.

  7. #17
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    So Bob, what happened with all your sabre-rattling arguments about...
    Quote Originally Posted by Bob Just
    ... I know lots of people - Oracle included - who would disagree.

    From a datatype standpoint alone, I disagree.

    You don't buy 10.57 bananas!

    "ItemQuantity" is an Integer. "TotalGallons" is a Real number. As such, they aren't logically the same thing.
    ?

    I can see a single "Quantity" field in the last version of your documentation. Are you going against your own convictions and the opinion of "lots of people -Oracle included" just to make me happy? that's very brave indeed.

    You know what... you are welcome! Oops... you forgot to say "thank you"

    Today is your lucky day Bob, here is a hint. In your current design -which in any way means I'm endorsing it - your sub-type tables should have a one-to-one relationship with your ExpenseDetail table, not a one-to-many with Expense table; it just doesn't work. I'm telling you this just because it hurt my eyes.

    Now you are free to say whatever you want -that's immaterial - you already know sooner or later you will have to revise it and do what I'm suggesting.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  8. #18
    Join Date
    Jan 2001
    Posts
    2,828
    Quote Originally Posted by PAVB
    your sub-type tables should have a one-to-one relationship with your ExpenseDetail table, not a one-to-many with Expense table;
    Hi

    I second that most of the Data Modelling books i have read seem to suggest the same what PAVB is suggesting.

    There should be one toone relationship between super and subtypes

    regards
    Hrishy

Posting Permissions

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


Click Here to Expand Forum to Full Width