Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Location
    Tehran
    Posts
    2

    Exclamation Unanswered: INSERT query for entities with IS-A relation

    Hi,
    this is my first post in this forum and it feels good to be in this forum.
    Here is my problem,
    I've a database for a shop which has a product table and few other tables which are sub-entities of the product.
    I mean this:
    telescope IS-A product
    book IS-A product
    DVD IS-A product
    now i have a primary key in product table(proid) and i have this key in each of the other sub-entities as their primary key. since i've modeled them this way, the product table contains only the common attributes and the other tables contain specific attributes for each product.

    the bumpy road begins here with data insertion. how should i insert the data for a telescope for example?
    inserting the data in product table is no pain, but how should i give the telescope table, the proid in the product table?
    help me please,

    SM

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    excellent first post, and congrats for modelling the supertype/subtype structure properly

    you'll want the LAST_INSERT_ID function
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Sep 2007
    Location
    Tehran
    Posts
    2

    Wink

    Quote Originally Posted by r937
    excellent first post, and congrats for modelling the supertype/subtype structure properly

    you'll want the LAST_INSERT_ID function
    Thanks alot r937
    I'll work on it and get back here for more

Posting Permissions

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