Professional Documents
Culture Documents
2 RDBMS
2 RDBMS
2 RDBMS
UNIT-II
(NORMALIZATION)
Q1) Define Normalization. Explain the three normalization forms.
They are :
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
In the above table the subject field is having two data. As a first normal form this should be
decomposed as :
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.
So after second normal form decomposition the tables looks like below:
STUDENT
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
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.
STU_DETAIL
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.
STATE_DETAIL
CITY STATE
HYD TELENGANA
MUMBAI MAHARASTRA
BANGALORE KARNATAKA
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
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
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
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.
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.
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.
1. PRIMARY
2. SECONDARY
3. CLUSTER
4. MULTI-LEVEL
6
PRIMARY INDEX:
INDEX EMP
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
INDEX EMP
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:
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----------------------