2.2.9 EntityKey

If the SMDL format specifies the value of an element or attribute as type EntityKey, it MUST be a valid Base64-encoded binary value [RFC3548], as specified in [XMLSCHEMA2] section 3.2.16 for xsd:base64Binary. The value MUST uniquely identify an instance of an entity.

An EntityKey is created from a composite of the key columns for the entity. The first byte contains a set of flags. The low seven flag bits are reserved and MUST be equal to zero. The high bit indicates whether the next set of bytes contains an optional null value bitmask. If the high bit is set to 1, the null value bitmask is present.

The null value bitmask, if present, has one bit per key column, rounded up to full bytes. Each bit set to 1 indicates that the corresponding column (keys ordered as above; high-to-low bits) contains a null.

The first byte and optional null value bitmask are followed by a binary serialization of the key columns of the table to which the entity is bound (or the column to which the entity is bound) in their native types. Key columns are serialized in the order in which they are defined in the primary key list in the physical model.

The structure of an EntityKey as a binary value is specified by the EntityKey structure and by the KeyValue structure, which specifies the structure of an individual key column. The description of these structures follows.

This document uses Augmented Backus-Naur Form (ABNF) as specified in [RFC5234] to specify the sequence of fields for the EntityKey and KeyValue structures that follow.