2 RDBMS

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

RDBMS

UNIT-II
(NORMALIZATION)
Q1) Define Normalization. Explain the three normalization forms.

Ans) Normalization is an analysis of functional dependency between the attributes of a


relation. Normalization process is used to create a good table structure. Normalization helps
to reduce data redundancy and minimizes data manipulations.

Normalization is done through some stages which are known as forms.

They are :

FIRST NORMAL FORM (1NF)

SECOND NORMAL FORM(2NF)

THIRD NORMAL FORM(3NF)

FIRST NORMAL FORM(1NF)

In a first normal form care is taken such that each field of the table should contain only
one data. If more than one data is present it is divided into two records.

STUDENT

S_CODE S_NAME SUBJECT DEPT_ID DEPT_NAME


101 A ENG,HINDI 10 ARTS
102 B TAX 11 COMMERCE
103 C PHY 12 SCIENCE

In the above table the subject field is having two data. As a first normal form this should be
decomposed as :

S_CODE S_NAME SUBJECT DEPT_ID DEPT_NAME


101 A ENG 10 ARTS
101 1 HINDI 10 ARTS
102 B TAX 11 COMMERCE
103 C PHY 12 SCIENCE

1
SECOND NORMAL FORM (2NF)

In the second normal form tables are created and relations are established between tables
using primary key, foreign keys etc.

Second normal form should fulfill 1NF and partial dependency

So after second normal form decomposition the tables looks like below:

STUDENT

S_CODE S_NAME SUBJECT DEPT_ID


101 A ENG 10
101 A HINDI 10
102 B TAX 11
103 C PHY 12

DEPT

DEPT_ID DEPT_NAME
10 ARTS
11 SCIENCE
12 COMMERCE

Here s_code is the primary key and Dept_id is the foreign key

THIRD NORMAL FORM (3NF)

The third normal form tells that it should fulfill 2NF and there should not be any Transitive
dependency . In a table if any two non-primary keys are inter-dependent this is called as
Transitive dependency.

So in the third normal form we should remove transitive dependency.

STU_DETAIL

SNO SNAME CITY STATE


101 A HYD TELENGANA
102 B HYD TELENGANA
103 C MUMBAI MAHARASTRA
104 D MUMBAI MAHARASTRA
105 E BANGALORE KARNATAKA
106 F BANGALORE KARNATAKA

2
In the above table two non-primary keys city and state are inter-dependent , if we edit
the city field we should also edit the state field correspondingly.

So after decomposition the tables looks like below:

SNO SNAME CITY


101 A HYD
102 B HYD
103 C MUMBAI
104 D MUMBAI
105 E BANGALORE
106 F BANGALORE

STATE_DETAIL

CITY STATE
HYD TELENGANA
MUMBAI MAHARASTRA
BANGALORE KARNATAKA

Q2) Explain Boyce-Code Normal form (BCNF)

This is also called as 3.5NF .

If in a table a Super key is used to decide a field data then again it should be done
normalization because still it is having Redundancy data.

STU_LECTURER

SNAME COURSE LECTURER


A BCOM S.ROY
B BSC B.RAJU
C BBA K.S.MURTY
D BCOM S.ROY

In the above table a primary key sname and a non-primary key course decides the lecturer. So
here a super key sname.course is used.

3
After decomposition the table looks like below:

COURSE

SNAME COURSE
A BCOM
B BSC
C BBA
D BCOM

LECTURER

COURSE LECTURER
BCOM S.ROY
BSC B.RAJU
BBA K.S.MURTY

Q3) Define file organization. Explain different file organizations.

Ans) A file is a collection of records of same type for example EMP,STU,PRODUCT


etc.

The way data is stored in a secondary storage device is known as file organization. File
organization refers to storing of data & accessing the data from the secondary storage device.
Secondary storage devices are HARD DISK, CD-ROM, DVD,PEN Drives

The main purpose of file organization is to :

 Efficient use of space


 Fast retrieval
 Easy maintenance
 Security from unauthorized use

Different file organizations are :


1. HEAP
2. SEQUENTIAL
3. INDEX SEQUENTIAL
4. RANDOM OR DIRECT (HASHED FILE ORGANISATION)

4
HEAP FILE ORGANISATION :

In this type of file organization the data is stored in any place in the file where space is
present. There is no order of storing.

The disadvantage in this type is lot of memory is wasted because data is placed in different
places. Again data retrieval is slow because it has to search the entire disk.

SEQUENTIAL FILE ORGANISATION:

In a sequential file organization data is stored one after the other. Hence as data is stored in
the same way we have to retrieve the data. For less volume of data it is good but for large
volume of data is not good because retrieval is slow . For example : data stored in Magnetic
tape comes in this category.

5
INDEX SEQUENTIAL:

In an index sequential data is first indexed and then stored sequentially. This is faster than
sequential file organization . For example: data stored in a Dictionary comes under this
category.

RANDOM OR DIRECT :

This is the best way of storing data and this is very fast. In this type of file organization data
can be retrieved directly irrespective of how the data is stored. Present secondary storage
device like HARD DISK,PEN DRIVE,DVD ,CD-ROM uses this technique.

Q4) What is an index? Explain different types of indexes.

Ans) Indexing is a data structure technique which is used to speed up the retrieval of data
from the database. In this type two files are maintained one for index and the other for
database. In the index file less data is stored whereas lot of data is stored in the database.

Different indexes are :

1. PRIMARY
2. SECONDARY
3. CLUSTER
4. MULTI-LEVEL

6
PRIMARY INDEX:

INDEX EMP

101 101 A 10000


102 102 B 12000
103 103 C 14000
104 104 D 16000
105 105 E 18000

A database is consisting of ‘n’ number of records. The index file holds all the primary
key data . When a query is fired the index file receives the query and matches the
corresponding record in the main database.
Here both the index file and the database is stored in the secondary memory storage .
Here the searching is very fast but lot of memory space is wasted.

SECONDARY INDEX

RAM SECONDARY MEMORY

INDEX EMP

101 101 A 10000


102 102 B 12000
103 103 C 14000
104 104 D 16000
105 105 E 18000

In this type the index table is stored in the RAM. The secondary memory holds the
original database. When a query is fired the index table matches the corresponding
record in the original table which is stored in the secondary memory and retrieves the
data .

7
Here as long as the database is in use the index file stores in RAM. After that
automatically it erases from the RAM.
The advantage is lot of secondary memory space is saved and data retrieval is very
fast. This is a good practice to retrieve data from a large database.

CLUSTERING INDEX:

INDEX DATABASE BLOCKS


A 1001 A
B 1002 B
C 1003 C
D 1004
D
E 1005
E

In this type data is stored as blocks. The blocks are having their associated address in
the database. For example department wise blocks are created in the database. This
takes more space. But data security is more because one type of data is present in the
block and there is no confusion.

MULTI-LEVEL INDEX

100

<50 >50

In this type of data the index table is divided into several parts . This is like a TREE
structure. Data is stored in a HIERARCHICAL way. This is also a fast retrieval
process and used for large database.
If 100 records are present first it stores first 50 records in one index file and next 50
records in the second index file.
The advantage is data is retrieved from a limited records so the data access is very fast
and saves a lot of time.
-------------------END----------------------

You might also like