sidebar

  LISTING 4: XDR Schema with Annotations That Creates an XML View

<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
           xmlns:dt="urn:schemas-microsoft-com:datatypes"
        xmlns:sql="urn:schemas-microsoft-com:xml-sql">

  <ElementType name="OrderDetail" sql:relation="[Order Details]" >
    <AttributeType name="ProductID" />
    <AttributeType name="Quantity" />
    <AttributeType name="UnitPrice" />
    <attribute type="ProductID" />
    <attribute type="Quantity" />
    <attribute type="UnitPrice" />
  </ElementType>


  <ElementType name="Customer" sql:relation="Customers">
    <AttributeType name="CustomerID" />
    <AttributeType name="ContactName" />
    <attribute type="CustomerID" />
    <attribute type="ContactName" />
  </ElementType>

  <ElementType name="Order" sql:relation="Orders" 
                            sql:key-fields="OrderID">
    <AttributeType name="OrderID" />
    <AttributeType name="OrderDate" /> 
    <attribute type="OrderID" />
    <attribute type="OrderDate" />

    <element type="OrderDetail">
      <sql:relationship key-relation="Orders" key="OrderID"
         foreign-key="OrderID" foreign-relation="[Order Details]" />
    </element>

    <element type="Customer" >
        <sql:relationship
            key-relation="Orders"
            key="CustomerID"
            foreign-relation="Customers"
            foreign-key="CustomerID" />
    </element>

   </ElementType>

</Schema>