key element key--element
Content model content-model-8
key:==keyfield
Attributes attributes-8
- @allowEmptyPart (boolean)
- @applicableIf (string)
- @internal (boolean)
- @label (string)
- @name (MNTOKEN)
- @noDbIndex (boolean)
Parents parents-8
<element>
Children children-8
<keyfield>
Description description-8
This element lets you define a key for identifying a record in the table.
A table must have at least one key.
Use and context of use use-and-context-of-use-6
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.
Attribute description attribute-description-8
- allowEmptyPart (boolean): in the case of a composite key, if this attribute is activated, they key is considered valid if at least one of its keys isn鈥檛 empty. If this is the case, the empty notion value is 鈥0鈥 (boolean or for all types of numerical data). By default, all the keys that make up a composite key need to be entered.
- applicableIf (string): this attribute lets you make the key optional. It defines the condition according to which the key definition will be applied. This attribute receives an XTK expression.
- internal (boolean): if it is activated, this attribute lets 蜜豆视频 Campaign know that the key is primary.
- label (string): label of the key.
- name (MNTOKEN): internal name of the key.
- noDbIndex (boolean): if it is activated (noDbIndex=鈥渢rue鈥), the field matching the key will not be indexed.
Examples examples-------
Declaration of a composite key which authorizes either the 鈥淍expr鈥 or the 鈥渁lias鈥 field to be empty:
<key name="node" allowEmptyPart="true">
<keyfield xpath="@expr"/>
<keyfield xpath="@alias"/>
</key>
Declaration of a primary key on the 鈥淣ame鈥 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);