fk*****@gmail.com wrote:
Hi all,
I have a problem with the issue in the subject, i have all data in one
big excel file,
in a denormalized form, and on the other side, i have mysql database
with many tables, which is already in production, and it is of course
in the 3rd NF. How do i go about importing that excel file , is there
any good tool i could use to handle prim/foreign key issues for me?
Any advice appreciated!
Thanks
There are two options. The first is to convert the excel file to CSV,
import it into the database in its own table, then populate the
normalised table using INSERT INTO table VALUES ( SELECT ... FROM
excel_table WHERE ... ); This doesn't work too well if you're using
auto incremented keys to join the values, though.
The second option is to just bite the bullet and write your own import
utility. Perl excels at string manipulation and DB access, but any
language will do. This is the better route if:
a) You use automatically incremented primary key fields
b) The data you're importing is not brand new, but must be linked to
existing records
c) It's not possible to go with option 1 due to complexity / lack of
identifying informaiton in the excel file.
Regards,
Ian