Difference between primary key and secondary key
Answers
Answered by
5
Primary Key
The attribute that uniquely identifies a row or record in a relation is known as primary key -like page number of a book
Secondary Key
A field or combination of fields that is basis for retrieval is known as secondary key (mainly used for finding details from large data)
.like an index page of a book
Primary Key: Is a single field chosen by the designer to uniquely identify a record in a table (relation), cannot be null (empty/unassigned).
Secondary Key:
The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key.
E.g. of Secondary Key can be Name, Address, Salary, Department_ID etc. as they can identify the records but they might not be unique.
The attribute that uniquely identifies a row or record in a relation is known as primary key -like page number of a book
Secondary Key
A field or combination of fields that is basis for retrieval is known as secondary key (mainly used for finding details from large data)
.like an index page of a book
Primary Key: Is a single field chosen by the designer to uniquely identify a record in a table (relation), cannot be null (empty/unassigned).
Secondary Key:
The attributes that are not even the Super Key but can be still used for identification of records (not unique) are known as Secondary Key.
E.g. of Secondary Key can be Name, Address, Salary, Department_ID etc. as they can identify the records but they might not be unique.
Answered by
7
Difference:
Primary key:
The primary key consists of one or more columns whose data contained within is used to uniquely identify each row in the table. You can think of the primary key as an address. If the rows in a table were mailboxes, then the primary key would be the listing of street addresses.
Secondary key:
A secondary key or foreign key is a set of one or more columns in a table that refers to the primary key in another table. There isn’t any special code, configurations, or table definitions you need to place to officially “designate” a foreign key.
Attachments:
Similar questions