Different Type of DBMS Keys and Example
- Primary Key is table-column which consist unique value and cannot be NULL. A table can have only one primary key in it. Primary Key is in sorted Order by Default.
- Unique Key is a table-column which consist unique value and it can be NULL. A Database Table can have many Unique Column in it.
- Foreign Key is a table-column or group of Table-column which set the relation between two table. Foreign Key of one table have the reference to the Primary key of another Table.
- Alternate Key is table Column or Group of column which identify each row in a table uniquely and not be NULL, But it is not a primary key. Alternate Key is Unique Identifier in table. In
- Super Key is set key of one or more table-column which identify the table row uniquely. Super Key set in below table is {REGNO}, {ROLLNO}, {REGNO,ROLLNO}
ID
|
REGNO
|
ROLLNO
|
FULLNAME
|
DOB
|
1
|
2020001435
|
10011
|
M Kumar
|
07-04-2003
|
2
|
2020001437
|
10012
|
MOHAMMED ISHAQ H
|
14-06-2002
|
3
|
2020001478
|
10013
|
ANBUSELVAM S
|
18-06-2004
|
4
|
2020001487
|
10014
|
MARTINPRIYADOSS J
|
08-03-2004
|
- Candidate Key is a column or group of column which consist unique value and not be Null. We select primary key from the group of candidate Key. We can say candidate Key is minimal set of Super Key with no duplicate record. {REGNO}, {ROLLNO}
- Primary Key can act as a Unique Key, but Unique Key can't be Primary key because it Can contain Null Value.
- Candidate key is Minimal set of Super Key with no redundant record.
Consider the Student_Info Table which contains Columns STUDENTID, ROLLNO, FIRSTNAME, LASTNAME, EMAILID. We will explain you the concept of keys in DBMS with example. Kindly go through the Student_Info table and explore your concept of all keys in DBMS below table.
STUDENTID | ROLLNO | FIRSTNAME | LASTNAME | EMAILID |
---|---|---|---|---|
1 | 08CS001 | John | Doe | john@example.com |
2 | 08CS003 | Umesh | Prasad | umesh@gmail.com |
3 | 08CS005 | Nithya | V | nithya@gmail.com |
Primary Key In DBMS : Defination, Rules
A Primary Key is a DBMS Table Key which is unique to each record in the table. It is Like unique Identifier tag of the table.
- Primary Key is a table Column which contain unique value and field can’t be Null.
- There will be Only One Primary key per Table.
- Primary Key can be considered as Candidate Key but Candidate key cannot be Primary Key.
- In Each Table Primary Key is sorted in Order.
- We can’t modify and update the primary key, if it is present in other table as a foreign Key.
No comments:
Post a Comment