Home > Blockchain >  many to many association in talend
many to many association in talend

Time:03-10

I have a job in talend to put data from a csv file into a databases, an empty table (Doctors),the id of tables doctors "doctorID" is a foreignkey is tables phones . how can i get the doctorID once is injected and associating in table phones. the table phones is also getting data from the same csv file. enter image description here

CodePudding user response:

You have to do it in 2 steps:
First load the doctors from the file into the Doctors table:

tFileInputExcel -- tMap -- Doctors

Then in the next subjob, lookup the doctors IDs from the doctors table and load the phones table:

                 Doctors (lookup on doctor key and get its ID)
                    |
tFileInputExcel -- tMap -- Phones

The above is needed if you are using an id generated by the database (auto increment), but if you are creating your own sequence, you can use your original design, and insert the sequence you created in tMap in phones table as a foreign key. This was the sequence is used both as the id for the doctors table, and a foreign key for the phones table.

CodePudding user response:

@Ibrahim Mezouar thank you for your answer, and if i want to add more new doctors with assoctiation with the phones. how can insert the new doctor from the last insertedID.

  • Related