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 > Bulk load, multiple tables with 1:m relationship

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-06, 04:46
nathanhaigh nathanhaigh is offline
Registered User
 
Join Date: Feb 2006
Posts: 1
Question Bulk load, multiple tables with 1:m relationship

I’m trying to implement a bulk upload feature to my database from a web frontend and I’d like to insert data into multiple tables where there is a 1:m relationship. The foreign key in the table on the many side of the relationship is an auto increment attribute in 1 side of the relationship.

For example:
table1 has a 1:m relationship to table2

table1
ID auto increment, primary key
Data varchar(50)

table2
ID auto increment, primary key
Table1_fk int
Data varchar(100)

Is there a way data could be bulk loaded into these tables from say, a tab delimited file? I have generated a bulk upload feature which takes columns from a file as the attributes to a particular table and this works where for example table1.ID is a user defined attribute, as the attribute can be included in an uploaded data file and used in the relationship. However, I can’t see an obvious way to do this if the attribute is an auto increment field.

Any thoughts!?

Cheers
Nath
Reply With Quote
  #2 (permalink)  
Old 02-18-06, 10:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
no

try designing this with a natural primary key, not a surrogate auto_increment
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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