Importance of Keys in DBMS

DBMS Keys
It is used to identify unique records by the combination of one or more fields(attributes) in the database table.
Keys play an important role in DBMS.

Different Types of Keys:

i) Candidate Keys – It is a minimal(minimum) set of attributes t…


This content originally appeared on DEV Community and was authored by hebaShakeel

DBMS Keys
It is used to identify unique records by the combination of one or more fields(attributes) in the database table.
Keys play an important role in DBMS.

Different Types of Keys:

i) Candidate Keys - It is a minimal(minimum) set of attributes that can identify each tuple/row uniquely in a Relation.

Example - In the below example of Employee relation, we can see that EPhone is the only unique attribute. Hence it can be treated as a Candidate Key.
Alt Text

ii) Primary Keys - It is a set of one or more attributes that can uniquely identify each tuple.
-> Primary Key cannot have "NULL" values.
-> Only one Primary Key is possible in a table.
-> Values of Primary Key are unique and they cannot be repeated.
-> One of the Candidate Keys is selected as the Primary Key.

iii) Super Keys - It is a superset of Candidate Keys.

-> Trivial Super Key - It is the set of all attributes.

iv) Foreign Keys - An attribute which is a key in one table and it also behaves as a Primary Key in another table is known as Foreign Key.
-> It is used to combine two tables logically.

v) Alternate Key - All other Candidate Keys which are not selected as a Primary Key is called as Alternate Keys. It is also called as Secondary Key.

vi) Composite Keys - If a key contains more than one attribute then it is called as a Composite Key.

Example: Employee table has key=>{eName, eAge, eAddress}. This key will be called as Composite Key.

Thank You!
See you soon.


This content originally appeared on DEV Community and was authored by hebaShakeel


Print Share Comment Cite Upload Translate Updates
APA

hebaShakeel | Sciencx (2021-06-07T14:40:43+00:00) Importance of Keys in DBMS. Retrieved from https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/

MLA
" » Importance of Keys in DBMS." hebaShakeel | Sciencx - Monday June 7, 2021, https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/
HARVARD
hebaShakeel | Sciencx Monday June 7, 2021 » Importance of Keys in DBMS., viewed ,<https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/>
VANCOUVER
hebaShakeel | Sciencx - » Importance of Keys in DBMS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/
CHICAGO
" » Importance of Keys in DBMS." hebaShakeel | Sciencx - Accessed . https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/
IEEE
" » Importance of Keys in DBMS." hebaShakeel | Sciencx [Online]. Available: https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/. [Accessed: ]
rf:citation
» Importance of Keys in DBMS | hebaShakeel | Sciencx | https://www.scien.cx/2021/06/07/importance-of-keys-in-dbms/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.