Tuesday, April 23, 2024

Types of Keys in DBMS

Here are the key points about different types of keys in the relational model:

1. Candidate Key:
   - It is a minimal set of attributes that can uniquely identify a tuple.
   - Every table must have at least one candidate key.
   - A table can have multiple candidate keys but only one primary key.
   - The value of the candidate key is unique and may be null for a tuple.

2. Primary Key:
   - It is a unique key that can identify only one tuple at a time.
   - It cannot have duplicate or null values.
   - It can be composed of more than one column.

3. Super Key:
   - It is a set of attributes that can uniquely identify a tuple.
   - Adding zero or more attributes to the candidate key generates the super key.

4. Alternate Key:
   - It is a candidate key other than the primary key.
   - All keys which are not primary keys are called alternate keys.

5. Foreign Key:
   - It acts as a primary key in one table and as a secondary key in another table.
   - It combines two or more relations at a time.

6. Composite Key:
   - It is used when a single attribute does not uniquely identify all the records in a table.
   - It is composed of multiple attributes and used together to uniquely identify rows in a table.

These types of keys are essential in database management systems as they help in distinct identification, relation development, and maintaining data integrity between tables. 

No comments:

Post a Comment