Keys in DBMS.pptx

Mastanvali72 47 views 9 slides Mar 30, 2023
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

database


Slide Content

Keys in DBMS Definition : A key is an attribute or set of attributes that uniquely identifies any record or tuple from the table . Purpose : Key is used to uniquely identify any record or row of data from the table . It is also used to establish and identify relationships between tables .

1. Super key A super key is a combination of attributes or set of attributes that can uniquely identifies the Each record of the relation. Example for super key . R(A,B,C,D) 1 1 5 1 SK=`{A}, {AB} , {AC} , {AD}, {ABC} ,{ACD}, 2 1 7 1 {ABD}, {ABCD}, 3 1 7 1 4 2 7 1 5 2 5 1

CANDIDATE KEY It is super key Whose proper subset is not a super key. It is minimal super key what is a subset ? S1={1,2,3} S2={1,2} Here s2 contains all elements of s1 hence S2 What is proper subset ? S2 ⊂S1 These two conditions must be satisfied 1.S2 ⊂ S1 2.S1 S2  

Example: R(A,B,C) 1 1 1 Super key = A, AB , AC, ABC , BC 2 1 2 3 2 1 Proper Subset of ABC=AB, BC, AC, A, B, C. 4 2 2 SK CK =It is super key Whose proper subset is not a super key. ABC YES NO AC YES NO A YES YES BC YES YES CANDIDATE KEYS = A, BC.

PRIMARY KEY : It is a candidate key that is most appropriate to become the main key in a table . In the above candidate keys we can select A OR BC as primary key IF we select ‘A’ as primary key then ‘BC ‘is a secondary key

COMPOSITE KEY Composite key consists of two or more attributes that uniquely identifies any record in a table . In this table student_id and subject _id together will form the composite key. Student _id Subject _id marks Exam_name

FOREIGN KEY It is an attribute in a table which is used to define its relationship with another table BRANCH TABLE BRANCH_CODE BRANCH_NAME HOD

Foreign key STUDENT TABLE In student and branch relationship the branch code can be made as a foreign key SID REG_ID NAME BRANCH_CODE EMAIL

GRACIAS……
Tags