Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    1

    Question Unanswered: Bulk load, multiple tables with 1:m relationship

    Im trying to implement a bulk upload feature to my database from a web frontend and Id 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 cant see an obvious way to do this if the attribute is an auto increment field.

    Any thoughts!?

    Cheers
    Nath

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    no

    try designing this with a natural primary key, not a surrogate auto_increment
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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