Keys

 Keys

In relational databases, keys are attributes (or a combination of attributes) that help identify records in a table and create relationships between tables. They are important for maintaining data accuracy and avoiding duplicate records.

🔹 Primary Key

A primary key uniquely identifies each row in a table. It cannot contain duplicate or NULL values. Each table can have only one primary key.

🔹 Candidate Key

A candidate key is any attribute that can uniquely identify a record. A table may have multiple candidate keys, but only one is selected as the primary key.

🔹 Super Key

A super key is a set of one or more attributes that uniquely identify a record. It may include extra attributes along with a candidate key.

🔹 Foreign Key

A foreign key is an attribute in one table that refers to the primary key of another table. It helps maintain relationships and ensures referential integrity.

🔹 Composite Key

A composite key is formed by combining two or more attributes to uniquely identify a record.

Keys are essential in relational databases because they ensure uniqueness, maintain relationships, and support data integrity.


 Click here

Comments

Popular posts from this blog

Views in Relational Databases

SQL

EMBEDDED SQL