Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 07: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, 07:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
excellent first post, and congrats for modelling the supertype/subtype structure properly

you'll want the LAST_INSERT_ID function
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #3 (permalink)  
Old 09-20-07, 08: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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On