Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the main use of sql alternate key

I am using sql server 2012. I want to just a use of Alternate Key in sql server that how can we use in our query and what is the actual logic of this. Can you give me suitable example of Alternate Key

like image 973
Naveen Avatar asked Oct 29 '25 14:10

Naveen


1 Answers

Assuming there is a table called Student with next structure

Create Table Student 
(
    StudentID int , 
    FirstName varchar(50), 
    LastName varchar(50), 
    CourseID int
)

Candidate keys are SID or FNAME+LAME

Primary Key: SID

Alternate Key: FNAME+LAME

now with some explanation

Candidate Keys are those keys which is candidate for primary key of a table. simply all columns which full fill all the requirements of primary key.

Alternate Key After choosing primary key from those candidate keys, rest of candidate keys are known Alternate Key.

like image 185
ahmed abdelqader Avatar answered Nov 01 '25 06:11

ahmed abdelqader