views:

251

answers:

1

In SQL Server you can use an XML datatype and map it to relational columns using an AXSD schema.

Mapping between XML and relational storage By using an annotated schema (AXSD), the XML is decomposed into columns in one or more tables. This preserves fidelity of the data at the relational level. As a result, the hierarchical structure is preserved although order among elements is ignored. The schema cannot be recursive.

from MSDN

However I cannot find any documentation on how to do this - or even a good page about AXSD.

Anybody got any good AXSD information. it seems very appropriate to what I want to do (temporarily use XML until i can migrate to something like nHibernate, but still allow a column view of certain pertanent data fields.

+1  A: 

Looks like this is the way to do it and this is helpful too.

And a free book too!

tip: search for 'annotated xsd schemass' and not AXSD!

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
  <xsd:element name="Employee" sql:relation="Employees" >
   <xsd:complexType>
     <xsd:sequence>
        <xsd:element name="FName"  
                     sql:field="FirstName" 
                     type="xsd:string" /> 
        <xsd:element name="LName"  
                     sql:field="LastName"  
                     type="xsd:string" />
     </xsd:sequence>
        <xsd:attribute name="EmpID" 
                       sql:field="EmployeeID" 
                       type="xsd:integer" />
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
Simon_Weaver