What Is The Primary Key, Super Key, Foreign Key And Candidate Key In The DBMS?

5

5 Answers

Rajesh Mehta Profile
Rajesh Mehta answered
Primary key - Primary key means main key
def:- A primary key is one which uniquely identifies a row
of a table. This key does not allow null values and also
does not allow duplicate values. For ex,
     empno   empname   salary
  1   firoz     35000
  2   basha     34000
  3   chintoo   40000

it will not the values as follows:
1   firoz   35000
1   basha   34000
  chintoo    35000

foreign key - a foreign key is one which will refer to a
primary key of another table

for ex,
  emp_table   dept_table
empno empname salary  deptno   deptno deptname

In the above relation, deptno is there in emp_table which
is a primary key of dept_table. That means, deptno is
refering the dept_table.

Super Key:- superkey is a set of columns within a
table whose values can be used to uniquely identify a row.

A candidate key is a minimal set of columns necessary to identify a row, this is also
called a minimal superkey. For example, given an employee table,
consisting of the columns employeeID, name, job, and departmentID, we
could use the employeeID in combination with any or all other columns
of this table to uniquely identify a row in the table. Examples of
superkeys in this table would be {employeeID, Name}, {employeeID, Name,
job}, and {employeeID, Name, job, departmentID}.
Naweed Jawaid Profile
Naweed Jawaid answered

What is a key?

A
key is an attribute (also known as column or field) or a combination of
attribute that is used to identify records. Sometimes we might have to
retrieve data from more than one table, in those cases we require to
join tables with the help of keys.  The purpose of the key is to bind
data together across tables without repeating all of the data in every
table.

Different types of keys?

Usage in Dbms : There are Different kind of keys .
primary key :- The attribute or combination of attributes that uniquely identifies a row or record.

Foreign Key:- an attribute or combination of attribute in a table whose value match a

primary key in another table.

Composite key:- A primary key that consists of two or more attributes is known as

composite key

candidate key:- is a column in a table which has the ability to become a primary key.

Alternate Key:- Any of the candidate keys that is not part of the primary key is called an alternate key.

Secondary key:- alternate of primary key.

Usage in dbms?

How To Use it ?
Ans: Its Depend on What DBMS you are using For Example you Using Sql You can use it by creating this Attribute as Primary key and use in Search Function. Remember that The Key Define Relationship Between attributes
So You can use it to modified,Delete,Search,or add Data

Hope this will help
Rajat Khosla Profile
Rajat Khosla answered

Super Key: An attribute or set of attributes that uniquely identifies a tuple within a  relation

Candidate key: A super key such that no proper subset is a super key within the relation

Primary key: The candidate key that is selected to identify
tuples uniquely within the relation, the candidate keys which are not
selected as PKs are called "Alternate keys"

Anonymous Profile
Anonymous answered
Primary key with example
shruti shreedharan Profile
According to me 2 types of keys are primary key and secondary key
primary key -has unique values and is used in a table for identity
eg:- students information tale should contain roll no as primary key so that even if name is similar, roll nos are different.

Answer Question

Anonymous