Add constraints or indexes

Constraints and indexes that are part of the database structure are displayed as part of the table, but additional constraints and indexes can be added.

Right-click the table in the meta-schema diagram and select Add Constraint or Index.


This figure is a screenshot of the Add Index or Constraint dialog.

Figure 1. Add Constraint or Index dialog

Specify the index type: Primary key, Secondary key, Index, or Unique index.

Primary Key
A Primary Key is a column or set of columns that uniquely identifies a row of data. The Not Null property must be set on the columns used in a Primary Key. The Not Null property indicates the column does not allow NULL values. It is used by the generation and update scripts when generating the SQL statements used to manage the database.
Secondary Key
Also known as a Unique Constraint. Like Primary Key, the Secondary Key ensure uniqueness on the columns it is defined, but also allows NULL values.
Index

An index improves the speed of looking up data in tables. Indexes can be defined on one or more table columns.

Unique Index
Unique Index behaves the same as an Unique Constraint. It ensures the data in the column is unique. The difference between a Unique Constraint and a Unique Index depends on the database engine.

The index can be viewed in the Structure view.


This figure is a screenshot of the Database Structure view. The added index is displayed in the treeview as a index node.

Figure 2. Database Structure view

Select the index to display its properties in the Properties view.


This figure is a screenshot of the properties of an index: Name, Columns, Type.

Figure 3. Properties view

If an index contains more than one column, the order of the columns is indicated.