Importing Parent-Child Data with XML Import

Previous Next

Parent-child data can be imported using XML.Import. For example: when the parent key is generated key.





'<?usoft-xml version="1.0" action="multi-tables-import" use-io-formats="no" verify-original-values="no" return-corrected-records ="yes"?>



<COMPANY NAME="Company A""1"/>



<DEPARTMENT NAME="Engineering""2">

<RELATE ROLE="HAS" href="#1"/>


<DEPARTMENT NAME="Support""3">

<RELATE ROLE="HAS" href="#1"/>




<EMPLOYEE NAME="Employee1" >

<RELATE ROLE="HAS" href="#2"/>


<EMPLOYEE NAME="Employee2" >

<RELATE ROLE="HAS" href="#3"/>






Company A is imported in COMPANY table

Engineering and Support are imported in DEPARTMENT table (with a generated primary key) and they are connected to Company A.

Employee1 is imported in EMPLOYEE table connected to Engineering department.

Employee2 is imported in EMPLOYEE table connected to Support department.

NOTE: To improve the performance of xml.import make sure that parent records are before child records in your XML document when using id-href constructions. An id can follow an href only if the foreign key of the child record is not part of the primary key or if foreign key is not mandatory, otherwise the href must follow the id (child record must be after the parent record in the XML document).