Creating a Unique Index

The primary key is an important concept in data processing. The primary key is a field or combination of fields in a record that allows you to uniquely identify a record from all the other records in a table. For example, companies assign IDs to employees as unique identifiers. Thus, an employee ID can serve as a primary key for personnel records.

When a table is created in Texis, duplicate records can be stored in the table. The uniqueness characteristic is not enforced automatically. To prevent duplicate records from being stored in a table, some steps must be taken.

First, a separate file called an "index" must be created. In this case the index is created so that the DBMS can ensure that all values in a special column or columns of a table are unique. For example, the EMPLOYEE table can be indexed on EID (employee ID) so that each row of the EMPLOYEE table contains a different employee ID value (i.e., no duplicate EIDs can be entered.)

A variation of the CREATE INDEX command, CREATE UNIQUE INDEX, is used to establish an index that assures no duplicate primary key values are stored in a table. The form of this command is:

CREATE [UNIQUE] INDEX index-name
     ON table-name (column-name [DESC] [,column-name [DESC]] ...) ;



Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.