One Star

Inserting data in MDM for "1 to many" relations

Hi,
I am a newbie to Talend. I'm having problems inserting "1 to many" relations in an entity.
I have created a test model and a test job.
I have two data sources (tfixedflowinputs) :
PERSON (id, nmperson, statutper)
ADRRESS, (id, city, statutadr)
My model consists of two entities and two complex types:
1) Entity SDU_PERSON with potentially many addresses (at least one).
 SDU_PERSON
  ->SDU_CT_PERSON
      idperson (auto increment)
      idreference
      nmperson
      statut
      adrperson
         -> SDU_CT_ADDRESS
             idaddress (auto increment)
             city
             statut
2) Entity SDU_ADDRESS
 SDU_ADDRESS
 -> SDU_CT_ADDRESS
        idaddress (auto increment)
        city
        statut
We created an entity address because an address can exist on its own without being linked to a person. (I'm really not sure the solution we implemented is the right way to go about it).
As input, we have the following :
PERSON (id, nmperson, statutper)
  (1, "Toto Patafix", false)
  (2, "Popo Pate", true)
ADDRESS (id, city, statutadr)
  (1, "Mahebourg", true)
  (2, "Quatre-Bornes", true)
  (2, "Curepipe", false)
To load the MDM (SDU_PERSON entity), we made a tMap between PERSON and ADDRESS, joining keys id.
In the MDM, I would have expected to have 2 persons created :
 - "Toto Patafix" with one address "Mahebourg"
 - "Popo Pate" with two addresses "Quatre-Bornes" and "Curepipe".
But what really happens is that 3 persons are created :
 - "Toto Patafix" with one address "Mahebourg"
 - "Popo Pate" with one address "Quatre-Bornes"
 - "Popo Pate" with one address "Curepipe".
I hope my description is clear. It has to be a basic simple thing to do but I really don't know how to go about it.
I am enclosing the job and the model.
Can someone please help me ?
Thanks
Sheila
2 REPLIES
Employee

Re: Inserting data in MDM for "1 to many" relations

Hello,
In order to create "Popo Pate" with 2 addresses, you need to send to MDM a XML record (using tMDMOutput component) that contains the 2 addresses. First create the Address instances:
<Address><city>Quatre-Bornes</city></Address>
<Address><city>Curepipe</city></Address>
Assuming the 2 Address were created with ids 1 and 2 and address FK is a repeatable element, you can create a Person record:
<Person><nmperson>Popo Pate</nmperson><adrPerson></adrPerson><adrPerson></adrPerson></Person>
Does it help?
One Star

Re: Inserting data in MDM for "1 to many" relations

Thank you for your post. I'll check it out asap (working on another issue right now) and come back to you.