Primary Keys

In client-server applications, users can now specify which field is to be used as the "primary key" by setting the value of "Index" in "Fields" to "pkey". A primary key field when present in a Zim table or used with ExecuteMode set to Zim Mode, behaves the same way as if there were a unique index on the field thus enabling duplicate values in indexed fields. This ensures easier migration of legacy data (which could contain duplicate values) to SQL servers, as there is no need to alter legacy data to ensure uniqueness of values.

The "primary key" attribute of a field removes any ambiguity as to which field Zim Client-Server uses as the primary key. If no field in a Zim table has the "primary key" attribute, Zim looks for the first field with a unique index as was done in the past. Primary keys should be defined only on the client side, not on the server side. To ensure that Zim can find the field with the primary key attribute, designate the primary key field as a required field.

Zim requires that each EntitySet and data relationship to be managed by the SQL database have at least one field defined as a "unique" index or pkey (primary key) index. The unique or pkey index is a primary key for the SQL table to which the entity set or data relationship corresponds. A primary key is necessary to directly access any record (row) of any SQL table. It does this by generating select statements which specify values for the primary key column(s) of the table.