Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Super and Sub Types - Where's the Forign Key Go?

Status
Not open for further replies.
Jan 9, 2003
147
US
I am working on building a reservation system and need a little help. Here's two links to my ERD and table layout (so far):


My question is, where does the forign key go in a supertype/subtype relationship?

My instincts tell me that it should go in the subtype (as it is in the tables image link above). But then adding a new record seems like a pain. I would have to add a record to the equipment table, then get the new equipment record's ID and use it when adding the second new record to one of the sub-type tables.

It would be easier to do it the other way around though, because the keys of the subtypes are serial numbers (so far anyway) and not autogenerated, it would be very easy to add the subtype IDs to the supertype table. But this feels "wrong".

I guess another option is to move all the properties to the subtype tables and have the supertype table only be a pointer to the correct subtype table (i.e. it would only have ID and SubTypeName for properties).

I hope I've explained my problem well enough. Please feel free to ask for any clarifications. I apreciate any help that can be provided.

Thanks,
Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top