A relational Database is a set of named relations. Relations are sometimes are known as table and generally representing an entity type . Key attribute is the attribute that uniquely
identifies an entity
Asian American Pacific Islander Month DDSD 2024.pptx
Keys in database
1. coursehunt.net - Search and discover online courses
Keys in Database
A relational Database is a set of named relations. Relations are sometimes are known
as table and generally representing an entity type. Each relation has a set of rows and
columns. Each row in a relation is termed as a tuple and each column represents an
attribute. Actually, each tuple represent an entity with its attributes.
In a relation, It is considered that no two tuples can represent same entity i.e two tuples
can’t have same values for all the attributes. Key attribute is the attribute that uniquely
identifies an entity or you can say, key attribute is that attribute for which two tuples
can’t have same values. This key attribute uniquely identifies an entity and all entities
will have different values for this attributes. Entities can have same or different values
for attributes other than key.
Consider the below given Relation STUDENT.
STUDENT
Name Roll-no Registration
Number
Contact
Number
address
Aman 1005 a-1008 9245657682 Mumbai
Adhrav 1006 a-1009 7663455624 Aurangabad
Aman 1007 a-1010 8436858788 Mumbai
Ansh 1008 a-1011 7476727424 Ahemdabad
In the above given relation STUDENT, there is a record for 4 students. For each
student, roll-no and registration numbers are different. No two students i.e tuples can
have same roll-no or registration numbers. These types of attributes for which no two
tuples can have same values are known as key attributes.
2. coursehunt.net - Search and discover online courses
On the other hand, we can’t consider name as key attribute because two students can
have same name as Aman in above given relation. Also, Address can’t be considered
as key attribute for same reason. Now we come to contact number. Looking at this
relation, it seems we can consider contact number also as key attribute but remember
to not .Because key attribute are generally considered which are universally unique for
a Relation as roll-no and registration number for students of same university can’t be
same. But contact number can be same in some conditions. For example, suppose
there are two brothers sharing same mobile phone because of some economic or other
reason, then for them we will have same contact number. Therefore, it is recommended
not to include contact number as key attribute.