Specify Relations Between Elements with No Nesting

When elements are not nested, no implicit relations are created. You can, however, explicitly specify relations between elements that are not nested by using the msdata:Relationship annotation.

The following example shows an XML Schema in which the msdata:Relationship annotation is specified between the Order and OrderDetail elements, which are not nested. The msdata:Relationship annotation is specified as the child element of the Schema element.

<xs:schema id="MyDataSet" xmlns=""
 <xs:element name="MyDataSet" msdata:IsDataSet="true">  
    <xs:choice maxOccurs="unbounded">  
      <xs:element name="OrderDetail">  
           <xs:element name="OrderNo" type="xs:string" />  
           <xs:element name="ItemNo" type="xs:string" />  
      <xs:element name="Order">  
           <xs:element name="OrderNumber" type="xs:string" />  
           <xs:element name="EmpNumber" type="xs:string" />  
       <msdata:Relationship name="OrdOrderDetailRelation"  

The XML Schema definition language (XSD) schema mapping process creates a DataSet with Order and OrderDetail tables and a relationship specified between these two tables, as shown below.

RelationName: OrdOrderDetailRelation  
ParentTable: Order  
ParentColumns: OrderNumber
ChildTable: OrderDetail  
ChildColumns: OrderNo
Nested: False  

See also