Creating Primary and Unique Keys in XML Schemas
A primary key defines a column in a table as unique and required (null values are not allowed), whereas a unique key defines a column in a table as unique and optional (null values are allowed).
You designate columns in tables as keys, which allow you to create relationships and constraints. For more information about keys, see Tables, Columns, Keys, and Constraints in XML Schemas.
The following is a visual representation of a Key definition in the XML Designer
To create a primary or unique key in an XML Schema or dataset
- Right-click to the left of the row of the element you want to designate as a key. Approximately where the key glyph is in the picture above.
- Click Add then click New Key.
The Edit Key dialog box appears.
- In the Name box, replace the default name with a name appropriate for this key.
The Selector box and the Field area will default to the element you chose in Step 1.
- If you need a key that is comprised of more than one column definition (a multipart key), select additional elements in the Field area.
- If you need to allow the element to contain a null value, select nullable.
- If you need a primary key, select Primary Key. Otherwise, a unique key will be created.
- Construct tables that will share this key data in order to define relationships. For more information, see Creating Tables in XML Schemas.
- You can now create a relationship with other tables that contain columns that are common to the key you just defined. For more information, see Creating DataRelation Objects with the XML Designer.
Relational Data in XML Schemas | Tables, Columns, Keys, and Constraints in XML Schemas | Nested Relationships in XML | Creating Tables in XML Schemas | Creating One-to-Many Relationships in XML Schemas and Datasets | Creating Nested Relationships in XML Schemas | XML Schemas and Data | XML Schemas and the XML Designer | Creating XML Schemas and Datasets | XML Files