How to Use CANDIDATE Keys

Last reviewed: April 30, 1996
Article ID: Q127846
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

A CANDIDATE key is an index expression that does not allow duplicate or NULL values. This articles provides examples that demonstrate the use of candidate keys.

MORE INFORMATION

By definition, a candidate key is a single field or a composite expression that meets the requirements of a primary key. It is a database design requirement that tables have one and only one primary key. A table might however contain several unique identifiers. Once the primary key has been identified, other unique keys are referred to as candidate keys.

In Visual FoxPro, primary keys are used to reinforce data integrity, and are therefore only available for tables included in a database. Free tables on the other hand can have candidate keys. Candidate keys can be used to ensure that a record is unique.

Following are two scenarios that might require the use of a candidate key in addition to a primary key.

Employee table: you have a table that records information about employees. Each employee can be identified by an employee identification number (primary key) and also by a social security number (candidate key).

Medical system: a table records patient information. Two fields can uniquely identify each patient: a medical record number (unique key) and a social security number (candidate key). The primary key provides a more intuitive way to search the data.

REFERENCES

"Developer's Guide", Visual FoxPro version 3.0, chapter 7, Working with

 Tables.

"A Guide to the SQL Standard", C.J. Date, p. 44, Addison-Wesley.


Additional reference words: 3.00 VFoxWin
KBCategory: kbprg
KBSubcategory: FxprgTable


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.