Unique Key
A Unique Key is similar to a Primary Key in that it can include one or more Columns whose value(s) identify a row as unique.
The difference is that the system allows null values in the Columns that are part of a Unique Key.
Any number of rows can include null (empty) values. A null in a Column (or even all Columns where allowed in a composite Unique Key) satisfies the Unique Key Constraint. However, you cannot have identical non-null values in the Columns of a partially null composite Unique Key Constraint.
If, as part of the definition of a Column that is part of a Unique Key, you disallow null values for that Column, the system does not allow null values there.
The Unique Key also serves as an index.
To define a Unique Key:
- Select Unique Key from the Type drop-down list. The system refreshes the lower portion of the screen and lists all the Columns you have defined in the current Table instance in the Table Columns side of the shuttle.
- Select the Column or Columns you want to be part of the unique key and move them into the Unique Key side of the shuttle. You can use Shift+Click or Ctrl+Click to select the Columns. You can double-click to move them or use the arrows.
- If necessary, use the Up and Down arrows to reorder the Columns in the key. You should have the most general Column at the top and the most granular at the bottom. For example, if your Unique Key is Patient, Visit, Test, you should list them in that order so that you can use the key as an index.
- Click Apply.
Parent topic: Defining Table Constraints and Indexes