Primary Key

<< Click to Display Table of Contents >>

 

Primary Key

A Primary Key is a field or a set of fields that uniquely identifies every record on a table. Just like the main index for a table, it is used to link data among tables. After defining a field as the table's primary key, the database ensures that no duplicated data is inserted in fields that are primary keys.

There are two types of primary keys, Simple and Composed. A Simple Primary Key is a field that uniquely identifies every record on a table. A Composed Primary Key can be performed by the combination of two or more table fields. There may have cases when a single field cannot work as a primary key because it contains repeated values. In addition, a table can have only one primary key, simple or composed, that is, users cannot define two or more fields from a table to be a separated primary key. Do not confuse it with a composed primary key, where the union of two or more fields forms a table's unique primary key. When selecting fields for a primary key, consider the following details:

Duplicated or null values are not allowed

If there is no unique identifier for a certain table, users can use a field that sequentially increments the records

 

A primary key can be created by clicking the check box corresponding to the field on column Primary key of the Historic. In this case, a PrimaryKey object is automatically created with the respective Primary Key Field already configured for the selected field.

Users can also create a primary key by right-clicking a Historic and selecting the Add - PrimaryKey option to add a PrimaryKey object, if it does not exist yet. Right-click the PrimaryKey object and select the Insert - Primary Key Field option. On the window that opens, select one of the available fields. After creating a primary key, users can change the field on the Field column and its sorting order, ascending or descending, on the Order column.

Was this page useful?