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.

What we have here is something XML does very well — hierarchies. In this case, we have a situation<br />

where customers have ordered different products. What our XML document is laid out to tell us is what<br />

products our customers have purchased. It seems like a reasonable question — doesn’t it?<br />

Note that this is a purely visual example — you do not need to load the Northwind samples here as this<br />

was purely an “in book” example.<br />

Now, time for me to twist things on you a bit — what if I change the question to be more along the lines<br />

of “Which customers have ordered each product?” Now our perspective has changed dramatically. At<br />

this point, a much better hierarchy would be one that had the products on the outside and the customers<br />

on the inside. Under that scenario, it would be our customers (rather than our products) that were<br />

repeated multiple times (once for each product), but it would get more to the root of our question.<br />

With XML coupled with XSL transformations, this is no big deal. You see, I don’t want to change the data<br />

that I’m looking at at all — I just need to transform my XML document so that I can look at it differently.<br />

Don’t confuse my saying “The way I look at the data” to mean how I visually look at it — what I’m<br />

talking about is more of how the data is perceived. Part of that is just how ready the data is to be used in<br />

a particular fashion. With our customers at the top of the hierarchy, our data doesn’t seem very ready<br />

for use to answer questions that are product focused. What I need is to change the data to be productfocused<br />

— just like my questions.<br />

So let’s look back at the same exact data, but transformed into another look:<br />

Chapter 16: A Brief XML Primer<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

515

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

Saved successfully!

Ooh no, something went wrong!