Nested Relationships in XML
In the hierarchical representation of data that XML provides, nested relationships are represented by parent elements that contain nested child elements.
The following example shows
Orders for a customer nested within a
Customers element. In other words, the data for both a customer and all their orders are grouped in a single nested hierarchy named
Customers. This differs from a one-to-many relationship where all customer information, as well as order information, would hierarchically exist at the same level and be related through the use of keys and keyrefs. For more information, see Tables, Columns, Keys, and Constraints in XML Schemas.
The follow example shows nested XML data:
<CustomerOrders> <Customers> <CustomerID>ALFKI</CustomerID> <Orders> <OrderID>10643</OrderID> <OrderDetails> <CustomerID>ALFKI</CustomerID> <OrderDate>1997-08-25</OrderDate> </Orders> <Orders> <OrderID>10692</OrderID> <CustomerID>ALFKI</CustomerID> <OrderDate>1997-10-03</OrderDate> </Orders> <CompanyName>Alfreds Futterkiste</CompanyName> </Customers> <Customers> <CustomerID>ANATR</CustomerID> <Orders> <OrderID>10308</OrderID> <CustomerID>ANATR</CustomerID> <OrderDate>1996-09-18</OrderDate> </Orders> <CompanyName>Ana Trujillo Emparedados y helados</CompanyName> </Customers> </CustomerOrders>
Relational Data in XML Schemas | Creating Nested Relationships in XML Schemas | XML Schemas and Data | XML Schemas and the XML Designer | Creating XML Schemas and Datasets | XML Files | Introduction to Data Access with ADO.NET | Introduction to Datasets