Introduction to RDBMS
What is a Relational Database?

As we discussed in the previous chapter, a database whose logical organization is based on relational data model is a Relational Database.

What is a Relational Database Management System (RDBMS)?

A DBMS that manages the relational database is known as RDBMS.

Keys

1. Candidate key

A Candidate key is a set of one or more attributes that can uniquely identify a row in a given table

Let's explain candidate key in detail using an example. Consider a table employee as given below

Example for Candidate key

(Assume that employee_id and email are unique)

In this example, attribute Employee_ID can uniquely identify a row of the table employee. Hence Employee_ID is a candidate key.Similary the attribute Email can also uniquely identify a row of the table employee. Hence Email is also a candidate key.

Hence for the table employee, we have two candidate keys - Employee_ID and Email.

2. Super key

Any superset of a candidate Key is a super key.

Let's explain super key in detail using the same employee table mentioned above. Here we can have many superkeys like {Employee_ID,FirstName}, {Employee_ID,LastName}, {Employee_ID,FirstName,LastName}, {Email,FirstName} etc because any superset of a candidate key is a superkey

3. Primary key

The Database designer will choose one key from the list of available candidate Keys to uniquely identify row in the given table.This key is known as primary key.

To select primary key from all candidate keys,

  • Preference is given to numeric column(s)
  • Preference is given to single attribute
  • Preference is given to minimal composite key

Let's explain primary key in detail using the same employee table mentioned above. Here we have two candidate keys - Employee_ID and Email. Remember our selection criteria for primary keys. Usually peference is given to numeric column(s). Hence we can select Employee_ID as the primary key of the table "employee".

4. Foreign key

A Foreign Key is a set of attribute (s) whose values are required to match values of a Candidate key in the same or another table

Let's explain Foreign key in detail using an example. Consider an employee table and a department table as given below

Foreign key

Here we can say that Department_ID of employee table is a foreign key refering Department_Number which is a candidate key of the department table.

A table which has a foreign Key referring to its own candidate key is known as self-referencing table.

The constraint that values of a given foreign key must match the values of the corresponding candidate key is known as referential constraint.

5. Non-Key Attributes

The attributes other than the Candidate Key attributes in a table/relation are called Non-Key attributes. In other words, the attributes which do not participate in any of the Candidate keys are called Non-Key attributes.

 
 
 
Comments(4) Sign in (optional)
showing 1-4 of 4 comments,   sorted newest to the oldest
Satya
2015-05-12 10:15:48 
Parent table is the table which contains actually the referred key, while the table which refers any table for a key is the child table. Here Employee Table is the Parent table and department table is the child one.
(1) (0) Reply
ALI MAMOON RIZWAN
2015-02-10 18:03:38 
Which table is parent table and whick table is child table ??
(0) (0) Reply
sunder singh
2012-09-06 13:32:13 
Plz give me non key attribute example.
(0) (0) Reply
kiran Bedre
2014-05-03 10:02:26 
from above table....

names can be same for many people so they cnt be expressed uniquely ... so these attributes froms non key attribute
(0) (0) Reply
 
Add a new comment...  (Use Discussion Board for posting new aptitude questions.)

Name:
Email: (optional)
8 + 4 = (please answer the simple math question)

Post Your Comment
X  
View & Edit Profile Sign out
X
Sign in
Google
Facebook
Twitter
Yahoo
LinkedIn
X