- Partial Key :
- Unique key :
It uniquely identifies a tuple in a relation. Unlike the Primary key, There can be more than one unique key in a table. It can accept only one null value. It cannot have duplicate values and it is non-updatable i.e. cannot be updated once it is assigned.
The best example of unique key is Voter ID.
Voter Id is unique for all the citizens. If it gets lost and another duplicate copy is issued, then the duplicate copy always has the same number as before. Thus, it is non-updatable. Few citizens may not have got their Voter Id, so for them, its value is NULL.
- Secondary Key :
It is a candidate key that is not selected as primary key. For example, we have schema: Student(Id, email, enroll_no, name) Candidate key of this relation is: ID, email, enroll_no
If we select Id as primary key, then email and enroll_no becomes secondary key of the relation.
- Composite key :
Up to 16 columns can be combined into a single composite index key initially using sqlplus earlier versions. However, the limit is extended and we can combine any number of columns (practically of no use)
- Surrogate key :
The surrogate key is internally generated.
Example : System date/time stamp, Counter
The set of attributes that are used to uniquely identify a weak entity set is called the Partial key. Only a bunch of the tuples can be identified using the partial keys. The partial Key of the weak entity set is also known as a discriminator.
It is just a part of the key as only a subset of the attributes can be identified using it. It is partially unique and can be combined with other strong entity set to uniquely identify the tuples.
Here we have an apartment as a weak entity and building as a strong entity type connected via ‘belongs to’ relationship set. Apartment number is not globally unique i.e. more than one apartment may have same number globally but it is unique for a particular building since a building may not have same apartment number. Thus apartment number cannot be primary key of entity Apartment but it is a partial key shown with a dashed line.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Primary and Secondary Memory
- Difference between Primary and Secondary Data
- Mathematics | Partial Orders and Lattices
- Total Recursive Functions and Partial Recursive Functions in Automata
- Hard Disk Drive (HDD) Secondary memory
- Types of Keys in Relational Model (Candidate, Super, Primary, Alternate and Foreign)
- Finding Attribute Closure and Candidate Keys using Functional Dependencies
- Role of keys in Cassandra
- Finding the candidate keys for Sub relations using Functional Dependencies
- Types of Keys in Data Warehouse Schema
- Difference between Primary key and Unique key
- Introduction of Relational Model and Codd Rules in DBMS
- Introduction to TimeStamp and Deadlock Prevention Schemes in DBMS
- Introduction of 4th and 5th Normal form in DBMS
- Difference between OLAP and OLTP in DBMS
- Difference between Row oriented and Column oriented data stores in DBMS
- Difference between RDBMS and DBMS
- Difference between 1NF and 2NF in DBMS
- Difference between DDL and DML in DBMS
- Main difference between Timestamp protocol and Thomos write rule in DBMS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.