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, a Primary Key is used to link data among tables. After defining a field as a table's Primary Key, the database ensures that no duplicated data is inserted in fields that are Primary Keys.

The types of Primary Keys are Simple and Composed. A Simple Primary Key is a field that uniquely identifies every record on a table. A Composed Primary Key can be formed by the combination of two or more fields of a table. There may have situations 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, either 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 numbers the records sequentially

 

A Primary Key can be created by clicking the option corresponding to the field on the Primary Key Primary Key column of a 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 this 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?