Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-13-2008, 11:56 PM
JRough
 
Posts: n/a
Default stored procedure to input data in a join table?

There is a many to many between cars and owners for rental
purposes so I added the company_car join table.

company:
companyId
company_type [owner, lessee]

company_car_join:
carID
companyID

car_owner:
carID
companyID
start_date
end_date

So I think I need a SQL query or a procedure to update the join table
from the car_owner table? This is as far as I got on the stored
procedure. If I need a SQL update query I don't know how to write it.

CREATE PROCEDURE update_car_comp_jn()

Begin
for each row in Comp_Car_Owner
set car_comp_join.comp_id = car_owner.comp_id
set car_comp_join.car_id = car_owner.car_id

END

I have one question on structure. Is it right I don't need an auto-
increment key since I can use the concatenated company_id and the
car_id as a unique key? I can drop the column company_id from
car_owner table.

thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:44 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.