1
What is the difference between a primary key and a secondary key?
1
Primary Key: - A primary key is a unique identifier for each record in a database table. - It must contain unique values and cannot be null. - Its main purpose is to uniquely identify each row in the table. - Examples: Student ID in a student table, Employee ID in an employee table. Secondary Key: - A secondary key is an attribute (or set of attributes) that can be used to search or retrieve records but does not necessarily uniquely identify a record. - It may contain duplicate values. - It is used for data retrieval based on non-unique attributes. - Examples: Last name, department name, or city in a customer table.
0
|
1
A Primary Key is a unique identifier for each record within a table, must be unique and not null, and a table can only have one. A Secondary Key is any key other than the primary key that uniquely identifies or partially identifies a record within a table. A table can have multiple secondary keys. Key differences include: Primary keys must be unique, while secondary keys may not be. A table can have only one primary key, but multiple secondary keys. Primary keys uniquely identify records, while secondary keys can be used for efficient data retrieval and may not always be unique.
0
|
1
A primary key uniquely identifies each record, while a secondary key is used for searching but may not be unique.
0
|