17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 16: A Brief XML Primer<br />

482<br />

Well, it doesn’t really take a rocket scientist to be able to discern the basics about our order at this point:<br />

❑ The customer’s ID number is 510.<br />

❑ The order ID number was 43663.<br />

❑ The order was placed on July 1, 2001.<br />

Basically, as we have things, it equates to a row in the SalesOrderHeader table in AdventureWorks<strong>2008</strong><br />

in <strong>SQL</strong> <strong>Server</strong>. If the customer had several orders, it might look something like:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

While this is a perfectly legal — and even well formed — example of XML, it doesn’t really represent the<br />

hierarchy of the data as we might wish. We might, for example, wish to build our XML a little differently,<br />

and represent the notion that customers are usually considered to be higher in the hierarchical<br />

chain (they are the “parent” to orders if you will). We could represent this by changing the way we<br />

express customers. Instead of an attribute, we could make it an element in its own right — including<br />

having its own attributes — and nest that particular customer’s orders inside the customer element:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!