Database Management

Database Keys[]

These keys are used in a database:

Primary Key – This key is utilized to identify a unique column or many columns as a unique identity. Every database table needs to have one or more columns that are designated to be a primary key. It may be selected for any number of reasons including convenience, comprehension, or performance. Once a primary key is picked and set up in the database, the DBMS will enforce its uniqueness. If you attempt to insert a record with a similar primary key, the insert will fail (

For example: If you have many employees you need to identify a column that will uniquely identify that employee only, in the entire database.

The primary key can not contain data that will be used again. It has to be completely functionally dependent and unique to the entire database.

Foreign Key – This is key is used to establish relationships between tables in a database. This key ultimately prevents a database from having redundant information in that when there is important information that is needed in more than one table a foreign key is used instead to establish a relationship so that both tables are linked and can display the appropriate information. When a foreign key is utilized then “referential integrity” is involved meaning that the column used as the foreign key must contain the same exact data in each table it is assigned as a foreign key.

These keys are used in a schema of a database associated to the relational model:

Candidate key – This key is a minimal super key and identifies individual tuples in a database. It is any set of one or more columns whose combined values are unique among all occurrences. No candidate key is allowed to be null because null values are not guaranteed to be unique ( Every table must have at least one candidate key, otherwise the design isn't finished (

Super Key – This key is considered to exist if NO two tuples contain the same values in their attributes in other words, are functionally independent. To look at it another way, a superkey is a set of columns within a table whose values can uniquely identify a row.

Alternative Keys -- These are the candidate keys that are not chosen to be the Primary key (