0% found this document useful (0 votes)
22 views

Keys in DBMS

The document discusses different types of keys used in database management systems including super keys, candidate keys, primary keys, alternative keys, foreign keys, and composite primary keys. It provides examples of each type of key using sample tables to illustrate how each uniquely identifies rows.

Uploaded by

BATHINI AJAY CSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Keys in DBMS

The document discusses different types of keys used in database management systems including super keys, candidate keys, primary keys, alternative keys, foreign keys, and composite primary keys. It provides examples of each type of key using sample tables to illustrate how each uniquely identifies rows.

Uploaded by

BATHINI AJAY CSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Keys in DBMS

===========
What is a Key:
==========
-> Key is an attribute or set of attrribute that can be used to determine row of
data in the table uniquely.
ex: consider the following relation student having attributes as
student (sid,sname,sbranch,smarks,smail,sphno)
-> From the above table sid, sphno,smail are consider as key.

Types of Keys:
===========
1) Super Key
2) Candidate Key
3) Primary Key
4) Alternative Key
5) Foreign Key
6) Composit/Compound Primary key

Super Key:
========
-> Super Key is an attribute or set of attrribute that can be used to determine row
of data in the table uniquely.

ex: consider the following relation student having attributes as


student (sid,sname,sbranch,smarks,smail,sphno)
-> From the above table sid, sphno,smail are consider as super key.

Super Key set : {sid,smail,sphno}

Candidate Key:
===========
-> Candidate Key is a minimal set of super key that helps you to identify rows of a
data in a table uniquely.
-> If any Proper subset of super key is a candidate key then that key is not a
super key

sid sphno smail -> Candidate Key


{sid,sphno}, {sid,smail}, {sphno,smail} ......-> Candidate Key

super key : {sid,sphno,smail}


candidate key : {sid,smail}

Alternative key:
===========
-> Alternative key is an attribute or set of attributes that are availble in super
key but not in candidate key
Example:
======
super key : {sid,sphno,smail}
candidate key : {sid,smail}
Alternative key : sphno
Primary Key:
=========
-> Primary key is an attribute that does't allows duplication values and NULL
values while entering the values under the primary key attribute.

-> A Table must and should have only one primary key attribute inorder to identify
records uniquely.
Example : Student(sid,sname,smarks,sphno,smail)
Primary key is : sid

Composit/Compound Primary Key:


========================
->Some times we need to take morethan one attributes as a key attributes, we call
it as Composit/compound Primary key.
Example : Student(sid,sname,smarks,sphno,smail)
Composit Primary key is : {sid,sphno}

Foriegn Key:
=========
-> Foriegn key is an attrinbute that establish relationship between two tables
-> Foriegn key is an attribute that allows you to enter the values those that are
present in primary key attribute of another table.
example
======
Emp(empid,empname,empsal,empadd,empphno) empid - primary key

Dept(empid,deptno,deptname,deptloc) empid - foreign key


Emp
====
empid empname empsal empadd empphno
111 smith 10000 ongole
222 jhon 20000 Addanki 76389

dept
===
empid deptno deptname deptloc
111 10 civil ff
111 20 mech sf -> allows
333 30 EEE tf -> won't allowed (since parent key is
not found)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy