Using XML Schema Collections

In this section, you define a simple XML schema, add it to a new schema collection stored on the server, and create a table where you can store instances of this schema. You also add a check constraint to ensure that the value of the ProductId attribute of the XML’s root node matches the value of the ProductId column, using the xml data type value() method (discussed later in this chapter, in the section, “The Built-in xml Data Type Methods”). The foreign key constraint you define on ProductId also serves to ensure that both ProductId values reference a primary key value in HumanResources.Product.

The real-world concept behind this sample schema is that it defines groups of customer feedback calls and subsequent ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.