Creating Valid ID, IDREF, and IDREFS Type Attributes Using sql:id-prefix
An attribute can be specified to be an ID type attribute. Attributes specified as IDREF or IDREFS can then be used to refer to the ID type attributes, thus enabling intradocument links.
ID, IDREF, and IDREFS correspond to PK/FK (primary key/foreign key) relationships in the database, with few differences. In the XML document, the values of ID type attributes must be distinct. If you have CustomerID and OrderID attributes in an XML document, these values must be distinct. However, in a database, CustomerID and OrderID columns can have the same values (for example, CustomerID = 1 and OrderID = 1 are valid in the database).
For the ID, IDREF, and IDREFS attributes to be valid:
- The value of ID must be unique within the XML document.
- For every IDREF and IDREFS, the referenced ID values must be in the XML document.
- The value of an ID, IDREF, and IDREFS must be named token (for example, integer value 101 cannot be an ID value).
- The attributes of ID, IDREF, and IDREFS type cannot be mapped to columns of type text, ntext, image, or any other binary data type (for example, timestamp).
If an XML document contains multiple IDs, to ensure the values are unique, sql:id-prefix annotation is used. For more information about sql:id-prefix, see Using sql:id-prefix.
See Also
IIS Virtual Directory Management for SQL Server