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 > Database Server Software > MySQL > INSERT query for entities with IS-A relation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-20-07, 06:13
saeeddb saeeddb is offline
Registered User
 
Join Date: Sep 2007
Location: Tehran
Posts: 2
Exclamation 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
Reply With Quote
  #2 (permalink)  
Old 09-20-07, 06:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
excellent first post, and congrats for modelling the supertype/subtype structure properly

you'll want the LAST_INSERT_ID function
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-20-07, 07:19
saeeddb saeeddb is offline
Registered User
 
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
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