How the XML schema maps to multiple interrelated forms
The Purchase Order and Line Item forms are related through their ID fields:
- Request ID on the Purchase Order form. This is the primary key in the parent form and it is unique. This is the key that establishes the relationship with the foreign key in the Line Item form.
- PO ID on the Line Item form. This is the foreign key in the child form; it establishes the relationship primary key in the Purchase Order form.
- Request ID on the Line Item form. This is the primary key in the child form, and it is unique.
- Line ID on the Line Item form. This is unique only in the subset of requests that reference the same Purchase Order form. The Line ID together with the PO ID form a "unique key."
The XML input document in the example can be represented as follows:
<Customer>XYZ Corp</Customer>
<Date>2/12/04</Date>
<Items>
<LineItem> <Id>1</Id> <Description>Memory</Description>
</LineItem>
<LineItem> <Id>2</Id> <Description>CPU</Description>
</LineItem>
<LineItem> <Id>3</Id> <Description>HardDisk</Description>
</LineItem>
</Items>
</PurchaseOrder>
The XML document does not include Request IDs. Request IDs have no meaning outside AR Systemunless they are used as the primary key identifier for the document. For example, if the purchase order (PO) document uses the Request ID field as the PO Number, that number is also used externally. In this case, the Request ID field is probably renamed as the PO Number field. The server automatically creates Request IDs for the parent and child forms, and assigns foreign keys to the child form as the identifier between the child and parent.
The only IDs in the XML document are the Line IDs of the child form. Line IDs can be numbers or strings, such as a description. Line IDs are used only in the modify operation — the server compares the existing complex document with the new document and determines which child items to modify, insert, and delete.