Mapping XML Schema (XSD) Constraints to DataSet Constraints

The XML Schema definition language (XSD) allows constraints to be specified on the elements and attributes it defines. When mapping an XML Schema to relational schema in a DataSet, XML Schema constraints are mapped to appropriate relational constraints on the tables and columns within the DataSet.

This topic discusses the mapping of the following XML Schema constraints:

  • The uniqueness constraint specified using the unique element.
  • The key constraint specified using the key element
  • The keyref constraint specified using the keyref element.

By using a constraint on an element or attribute, you specify certain restrictions on the values of the element in any instance of the document. For example, a key constraint on a CustomerID child element of a Customer element in the schema indicates that the values of the CustomerID child element must be unique in any document instance and that null values are not allowed.

Constraints can also be specified between elements and attributes in a document, in order to establish a relationship within the document. The key and keyref constraints are used in the schema to specify the constraints within the document, resulting in a relationship between document elements and attributes.

The mapping process converts these schema constraints into appropriate constraints on the tables created within the DataSet.

In This Section