SQl Candidate, Super, Primary, Foreign Key Types with Example -DeveloperIndian
#candidate key sql #candidate key in dbms #keys in rdbms
"Each record in a table is given a special identification by the PRIMARY KEY constraint. Primary keys cannot have NULL values and must have UNIQUE values. There can only be one main key in a table."
Below is example of Primary Key :
employee table -> employee(emplyee_id, NAME, ADDRESS, PHONE) , emplyee_id is a primary key
A candidate key is the bare minimum set of attibute that can successfully identify a tuple. As An Example
emp table -> emp (emplyee_id, NAME, ADDRESS, PHONE)
employee_id is the candidate key for relation emp.
"A subset of the super key known as a "candidate key" is capable of uniquely identifying the other table properties."
Every table must have at least a single candidate key.
A field (or group of fields) in one table that refers to the PRIMARY KEY in another table is known as a FOREIGN KEY. The foreign key table is known as referenced or parent table.
:A tuple's set of properties that can be used to identify it exclusively is referred to as a super key. A super key is a collection of one or more keys that distinguishes the rows in a database. It allows for NULL values.
"The super key is created by adding 0–more properties to the candidate key.
Super keys are candidate keys, but the opposite is not true."