title: What is the purpose of XSD files?
body: <p>Since we can query on the XML file from C# (.NET), why do we need an XSD file? I know it is metadata file of particular XML file.  We can specify the relationships in XSD, but what is its functioning then? </p>
  
  <h2>XML</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Root&gt;
    &lt;Customers&gt;
      &lt;Customer CustomerID="GREAL"&gt;
        &lt;CompanyName&gt;Great Lakes Food Market&lt;/CompanyName&gt;
        &lt;ContactName&gt;Howard Snyder&lt;/ContactName&gt;
        &lt;ContactTitle&gt;Marketing Manager&lt;/ContactTitle&gt;
        &lt;Phone&gt;(503) 555-7555&lt;/Phone&gt;
        &lt;FullAddress&gt;
          &lt;Address&gt;2732 Baker Blvd.&lt;/Address&gt;
          &lt;City&gt;Eugene&lt;/City&gt;
          &lt;Region&gt;OR&lt;/Region&gt;
          &lt;PostalCode&gt;97403&lt;/PostalCode&gt;
          &lt;Country&gt;USA&lt;/Country&gt;
        &lt;/FullAddress&gt;
      &lt;/Customer&gt;
    &lt;/Customers&gt;
    &lt;Orders&gt;
      &lt;Order&gt;
        &lt;CustomerID&gt;GREAL&lt;/CustomerID&gt;
        &lt;EmployeeID&gt;6&lt;/EmployeeID&gt;
        &lt;OrderDate&gt;1997-05-06T00:00:00&lt;/OrderDate&gt;
        &lt;RequiredDate&gt;1997-05-20T00:00:00&lt;/RequiredDate&gt;
        &lt;ShipInfo ShippedDate="1997-05-09T00:00:00"&gt;
          &lt;ShipVia&gt;2&lt;/ShipVia&gt;
          &lt;Freight&gt;3.35&lt;/Freight&gt;
          &lt;ShipName&gt;Great Lakes Food Market&lt;/ShipName&gt;
          &lt;ShipAddress&gt;2732 Baker Blvd.&lt;/ShipAddress&gt;
          &lt;ShipCity&gt;Eugene&lt;/ShipCity&gt;
          &lt;ShipRegion&gt;OR&lt;/ShipRegion&gt;
          &lt;ShipPostalCode&gt;97403&lt;/ShipPostalCode&gt;
          &lt;ShipCountry&gt;USA&lt;/ShipCountry&gt;
        &lt;/ShipInfo&gt;
      &lt;/Order&gt;
      &lt;Order&gt;
        &lt;CustomerID&gt;GREAL&lt;/CustomerID&gt;
        &lt;EmployeeID&gt;8&lt;/EmployeeID&gt;
        &lt;OrderDate&gt;1997-07-04T00:00:00&lt;/OrderDate&gt;
        &lt;RequiredDate&gt;1997-08-01T00:00:00&lt;/RequiredDate&gt;
        &lt;ShipInfo ShippedDate="1997-07-14T00:00:00"&gt;
          &lt;ShipVia&gt;2&lt;/ShipVia&gt;
          &lt;Freight&gt;4.42&lt;/Freight&gt;
          &lt;ShipName&gt;Great Lakes Food Market&lt;/ShipName&gt;
          &lt;ShipAddress&gt;2732 Baker Blvd.&lt;/ShipAddress&gt;
          &lt;ShipCity&gt;Eugene&lt;/ShipCity&gt;
          &lt;ShipRegion&gt;OR&lt;/ShipRegion&gt;
          &lt;ShipPostalCode&gt;97403&lt;/ShipPostalCode&gt;
          &lt;ShipCountry&gt;USA&lt;/ShipCountry&gt;
        &lt;/ShipInfo&gt;
      &lt;/Order&gt;
    &lt;/Orders&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>I want to get data from the <code>Order</code> elements according to a provided <code>CustomerID</code>.</p>
  
  <p><strong>Also</strong>: What is the purpose of giving the relationships in XSD?</p>