Home  >  Article  >  Database  >  Secondary keys in RDBMS

Secondary keys in RDBMS

WBOY
WBOYforward
2023-09-06 08:25:021211browse

RDBMS 中的辅助键

What is a secondary key

A secondary key is a key that has not been selected as a primary key. However, it is considered a candidate key for the primary key.

Therefore, candidate keys that are not selected as primary keys are called secondary keys. A candidate key is an attribute or set of attributes that you can think of as a primary key.

Note: Secondary keys are not foreign keys.

Example

Let’s look at an example −

##096055##9122699Shreyas28 Above, Student_ID, Student_Enroll and
Student_ID

Student_Enroll

Student_Name

##Student_Age

Student_Email

9122717

Manish

25

##aaa@gmail.com

9122655

Manan

23

abc@gmail.com

##067

##pqr@gmail.com

Student_Email

are candidate keys. They are considered candidate keys because they uniquely identify student records. Select one of the candidate keys as the primary key. The remaining two keys will become secondary keys.

Assume that you selected Student_ID as the primary key, so Student_Enroll and

Student_Email

will become secondary keys (candidate keys for the primary key). ExampleLet’s look at another example −

Employee_ID

E7897 Tomtom@example.comOperationsEmployee_Email are candidate keys. They uniquely identify employee records. Select one of the candidate keys as the primary key. The remaining two keys will become secondary keys.
Employee_No

Employee_Name

Employee_Email

Employee_Dept

##0989

Jacob

##jacob@example.com

Finance

0777

E8768

Anna

anna@example.com

HR

##0656

E8789

Above, Employee_ID, Employee_No

and

The above is the detailed content of Secondary keys in RDBMS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete