This element lets you define a key for identifying a record in the table.
A table must have at least one key.
As a rule, keys are declared after the main element of the schema and the indexes.
A key is known as composite if it includes several fields (i.e. several
<keyfield> children). Do not use a composite key to define a primary key.
If the main element of the schema contains the “@autopk=true” attribute, the primary key is unique. We can only have one primary key per schema.
The first 1000 identifiers are reserved, so if a range of values needs to be defined for keys, start at 1000.
Declaration of a composite key which authorizes either the “@expr” or the “alias” field to be empty:
<key name="node" allowEmptyPart="true"> <keyfield xpath="@expr"/> <keyfield xpath="@alias"/> </key>
Declaration of a primary key on the “Name” field of STRING type in an
<srcschema> and the matching SQL query:
<key name="PrimaryKey" internal="true"> <keyfield xpath="@name"/> </key> CREATE UNIQUE INDEX Schema_PrimaryKey ON Schema(sName);