You are on page 1of 11

ASSIGNMENT

DRIVE FALL 2013


PROGRAM MBA IT
SUB1ECT CODE &
NAME
MI0034- DATABASE MANAGEMENT SYSTEMS
SEMESTER 3
BK ID B1217
CREDITS 4
MARKS 60
Q.1 How is DBMS classified based on several criteria? Explain each one of them with few
examples where ever required
Ans : Several criteria are normally used to classify DBMSs. These are discussed below:
1. Based on data model
2. Based on the number of users
3. Based on the ways database is distributed
1. Based on data model:
t s!ecifies a !articular mechanism for data stora"e and retrieval. The !rimary difference between
the different database models lies in the methods of e#!ressin" relationshi!s and constraints
amon" the data elements. $ive database models are discussed here:
1. Hierarchical Model: t is one of the oldest database models %1&'(s)* and re!resents data as
hierarchical tree structures.
2. Network Model: t re!resents data as record ty!es* and has an ability to handle many+to+many
relationshi!s.
3. Relational Model: ,elational models stores data in the form of a table. Data is interrelated-
relationshi!s lin. rows from two tables. /nd+users need not .now about !hysical data stora"e
details. So it is conce!tually sim!le.
0. Object Oriented model: t is based on a collection of ob1ects. 2b1ect oriented database
mana"es ob1ects* and is suited for multimedia a!!lications as well as data with com!le#
relationshi!s that are difficult to model and !rocess in a relational DBMS. 2b1ect 2riented Data
Base Mana"ement System %22DBMS) holds data* te#t* !ictures* voice and video.
'. Object-relational model: t is a combination of both ob1ects oriented conce!ts and relational
conce!ts. t combines the advanta"es of modern ob1ect oriented !ro"rammin" lan"ua"es* which
!rovide facility for the users to define new data ty!e and functions of their own. ,elational
database is not only useful for storin" data* but also !rovides business rules that are a!!lied to the
data. Associatin" rules with data ma.es the data more active* enablin" the database system to
!erform automatic validity chec.s to automate many business !rocedures. t su!!orts s!eciali3ed
a!!lications such as ima"e retrieval* searchin"* multimedia* etc.
/". BM4s DB2 universal server* oracle 5 and S67 server 8 and so on.
B. Based on number of users: t is based on number of users su!!orted by the system. Sin"le
user system su!!orts only one user at a time and multi+user system su!!orts multi!le users
concurrently.
9. Based on number of sites: A DBMS is centrali3ed if the data is stored at a sin"le com!uter
site. A DBMS is distributed if the data and DBMS software are distributed over many sites*
connected by a com!uter networ..
Q.2 Differentiate between B+ tree and B- tree. Explain them with diagrams
Ans: The main disadvanta"e of the inde#+
se:uential file or"ani3ation is that !erformance
de"rades as the file "rows. A B;+tree inde# ta.es
the form of a balanced tree in which every !ath
from the root of the tree to a leaf of the tree is of
the same len"th.
n a B+ tree every value of the search field a!!ears
once at some level in the tree* alon" with a data
!ointer %may be in internal nodes also). n a B;+
tree* data !ointers %address of a !articular search
value) are stored only at the leaf nodes of the tree-
hence* the structure of leaf nodes differs from the
structure of internal nodes. The leaf nodes have an
entry for every value of the search field* alon"
with a data !ointer to the record.
A B; tree is a multilevel inde#* but it has "ot
different a structure. A ty!ical node of the B; tree
contains u!to n+1 search .ey values such as
.1*.2<<.n+1 and n !ointers !1*!2<..!n. The
search .ey values within a node are .e!t in sorted
order* .i = .1.
The number of pointers in a node is called the
fan out of the node.
The structure of a non+leaf node is the same as leaf nodes* e#ce!t that all !ointers are
!ointers to tree nodes.
/ach internal node is of the form >!1* .1*!2*.2<.!:+1* .:+1* !:>
The root node has at least 2 tree !ointers.
/ach leaf node is of the form
==.1* !r1>*=.2* !r2><<=.n+1* !rn+1>* !ne#t>
each !ri is a data !ointer* and !ne#t !oints to the ne#t leaf node of the B; tree
All leaf nodes are at the same level.
The main difference is that a B tree eliminates the du!licate stora"e of search ? .ey values. n the
B; tree every search .ey value a!!ears in some leaf nodes and several are re!eated in non+leaf
nodes. AB ? tree allows search ? .ey values to a!!ear only once* hence B ? tree re:uires fewer
nodes. @owever* since the search+.eys a!!ear only once* in a B ? tree* every node contains search
value alon" with an address of that value %!ointer !oint either to file records or to buc.ets that
contain the search value).
9onsider the to! node* which consists of two value entries %' and 5) and three !ointers. Aalues
less than ' or e:ual to ' are !laced in the left lower node* similarly values "reater than ' and less
than 5 are !laced in the middle node* and "reater than 5 are !laced in the ri"ht lower node.
9onsider an al"orithm of B+trees.
Set B to the to! node
7et C* D be the data values in node
B %#=y)
f A=EC
Then set B to the left lower node of
B
f C* A =ED
Then set B to middle lower node of
B
f A > D
Then set B to ri"ht lower node of B
/nd
f A occurs in node B then e#it %found)
f A does not occur in node B then e#it %not found)
A B ? tree starts with a sin"le root node %which is also a leaf node) at level ( %3ero). 2nce the root
node is full with ! ? 1 search .ey values* we attem!t to insert another entry in the tree* the root
node s!lits into two nodes at level 1. 2nly the middle value is .e!t in the root node* and the rest
of the values are s!lit evenly between the other two nodes. Fhen a non root node is full and a
new entry is inserted into it* that node is s!lit into two nodes at the same level* and the middle
entry is moved to the !arent node alon" with two !ointers to the s!lit nodes. f the !arent node is
full* it is also s!lit. S!littin" can !ro!a"ate all the way to the root node.

Q.3 Employee Department
Emp Id Name Project Salary Dep. no.
MUL 1 Ramya PR 1 40000 1
MUL 2 Nupur PR 1 45000 2
SMU 1 Rajesh PR 3 20000 2
SMU 2 Vinay PR 2 50000 3
SMU 3 Anil PR 2 80000 2
Using these tables answer the following question
a. If we want to see all the employees with salary between 40000 and 50000, which query
can be used?
b. Select employee name from EMPLOYEE table, whose name starts with R
c. Explain aggregate functions and grouping in detail
Ans : Select Count DNAME, EmpID from employee join department on Employee dept-
NUM Department. DEPT-ID having salary >20000 group by DName.

AGGREGATE FUNCTIONS AND GROUPING:
Grou! by clause is used to "rou! the rows based on certain common criteria- for e.". we can
"rou! the rows in an em!loyee table by the de!artment. $or e#am!le* the em!loyees wor.in" for
de!artment number 1 may form a "rou!* and all em!loyees wor.in" for de!artment number 2
form another "rou!. Grou! by clause is usually used in con1unction with a""re"ate functions li.e
SHM* MAC* Min etc.. Grou! by clause runs the a""re"ate function described in the S/7/9T
statement. t "ives summary information.
Example: $or each de!artment* retrieve the de!artment number* the number of em!loyees in
the de!artment and their avera"e salary.
S/7/9T Dno* count IJK LBo. of /m!loyeesL
$,2M em!loyee
G,2HM BD DB2-
OUT PUT
HAVING CLAUSE:
The havin" clause filters the rows returned by the "rou! by clause.
/": 1>Select 1ob* count IJK from em! "rou! by 1ob havin" count IJK>2(-
2>Select De!tno*ma#IbasicK* minIbasicKfrom em! "rou! by Detno havin" salary>3((((
find the avera"e salary of only de!artment 1.
S/7/9T Dn2*av"IsalaryK
$,2M /m!loyee
G,2HM BD Dno
@AABG Dno E 1-
@ere whereNclause limits the tu!les to which functions are a!!lied* the havin" clause is used to
select individual "rou!s of tu!les.
$or each de!artment that has more than three em!loyees* retrieve the de!artment number and
the number of its em!loyees* who are earnin" more than 1(*(((.
Example:
S/7/9T Dno* AAG IsalaryK
$,2M /m!loyee
F@/,/ Bdate 7O/ 4P1anP4
G,2HM BDDno
@AABG ma# IsalaryK > 1((((-
Dept id D name Place
1 MIS Bangalore
2 HRM Bangalore
3 Finance Chennai
4 Research Bangalore
DNO No. of
Employees
3( 2
0( '
'2 3
'3 0
OUT PUT:
DB2 AAG ISA7A,DK
1 22(((
2 15(((
3 2((((
Q.4 What are the problems and failures that may encounter with respect to the transactions
in a database management system? Give examples.
Ans : A transaction is a lo"ical unit of wor.* which involves may database o!erations. A
transaction is a collection of o!erations that forms a sin"le lo"ical unit of wor.. A transaction is a
unit of !ro"ram e#ecutions that accesses and !ossibly u!dates various databases. /#am!le:
Ban.in" system* Student database !erforms transactions.
Problems with code :
1. The lost update problem: Su!!ose transactions T1 and T2 are submitted at the same time*
when these two transactions are e#ecuted concurrently as shown in fi". a* then the final value of #
is incorrect. Because T2 reads the value of #
before T1 chan"es it in the database* and hence
the u!dated value resultin" from T1 is lost.
$or e.".: #E5( at the start I5( reservation at the
be"innin"K* nE' IT1 transfers ' seat reservation
from the fli"ht # to yK* and mE0 IT2 reserves 0
seats on #K* the final result should be #E8& but
due to interleavin" of o!erations #E50* because
u!datin" T1 that removed the ' seats from # was
lost.
2. Dirty read problem: This !roblem occurs when one transaction u!dates a database item and
then the transaction fails for some reason. The u!dated item is
accessed by another transaction before it is chan"ed bac. to its
ori"inal value.
$or e.".: T1 u!dates item # and then fails before com!letion*
so the system must chan"e # bac. to ori"inal value. Before it
can do so* however* transaction T2 reads the tem!orary value
of #* which will not be recorded !ermanently in the database*
because of the failure of T1. The value of item # that is read by
T2 is called Dirty Data* because it has been created by a
transaction that has not been com!leted and committed yet.
@ence this !roblem is also .nown as the tem!orary u!date !roblem.
3. Incorrect Summary Problem: f one transaction is calculatin" an a""re"ate summary
function on a number of
records* while other
transactions are u!datin"
some of these records* the
a""re"ate function may
calculate some values
before they are u!dated
and others after they are
u!dated.
$or e#: Transaction T3 is
calculatin" the total no. of
reservations on all the
fli"hts* meanwhile
transaction T1 is
e#ecutin". The T3 reads
the values of # after n
seats have been subtracted
from it* but reads the
value of y before those n seats have been added to it.
Types of failures:
1. A computer failure (System Crash):
@ardware* software* networ. error occurs in the com!uter system durin" transaction
2. Transaction or system error:
Some o!eration in the transaction may cause it to fail* such as inte"er overflow or division by
4Qero4 etc.
3. Local errors or exception conditions detected by the transaction:
Durin" transaction e#ecution* certain conditions may occur that !erform cancellation of the
transaction. $or e#. Data for the transaction my not be found.
4. Concurrency control enforcement:
The concurrency control method may decide to abort the transactions* to be restarted later*
because several transactions are in a state of deadloc..
5. Disk failure:
Some dis. bloc.s may lose their data because of read or write malfunctions
6. Physical problems and catastrophes:
This refers to a list of !roblems that includes !ower or air conditionin" failure* fire* theft*
overwritin" dis.s etc.
Q.5 Consider any database of your choice (may be simple banking database/forecasting
database/project management database). Show the deduction of the tables in your database
to the different types of normal forms
Ans : .5 normal forms with respect to the database
Normal forms Based on Primary Keys
A relation schema , is in first normal form if every attribute of , ta.es only sin"le atomic values.
To transform the un+normali3ed table Ia table that contains one or more re!eatin" "rou!sK to first
normal form* we identify and remove the re!eatin" "rou!s within the table
E.g.
This is not in first normal form because D. location is not an atomic attribute. The domain of D
location contains multivalues.
Given a relation ,* a set of attributes C in , is said to functionally determine another attribute D*
in ,* IC+>DK if and only if each value of C is associated with one value of D. C is called the
determinant set and D is the de!endant attribute.
Second Normal Form (2 NF)
A second normal form is based on the conce!t of full functional de!endency. A relation is in
second normal form if every non+!rime attribute A in , is fully functionally de!endent on the
Mrimary Oey of ,.
De!t.
D.Bame
D.B
o
D. location
,RD ' %/n"land* 7ondon* DelhiK
@,D 0 Ban"alore
A Martial functional de!endency is a functional de!endency in which one or more non+.ey
attributes are functionally de!endent on !art of the !rimary .ey. t creates a redundancy in that
relation* which results in anomalies when the table is u!dated.
Third Normal Form (3NF)
This is based on the conce!t of transitive de!endency. Fe should desi"n relational schema in
such a way that there should not be any transitive de!endencies* because they lead to u!date
anomalies. A functional de!endence %$D) #+>y in a relation schema 4,4 is a transitive
de!endency. f there is a set of attributes 4Q4 7e #+>* 3+>y is transitive. The de!endency SSB+
>Dm"r is transitive throu"h Dnum in /m!Nde!t relation because SSB+>Dnum and Dnum+
>Dm"r* Dnum is neither a .ey nor a subset %!art) of the .ey.
Boyce Codd Normal Form (BCNF) Database relations are desi"ned so that they are neither
!artial de!endencies nor transitive de!endencies* because these ty!es of de!endencies result in
u!date anomalies. functional de!endency describes the relationshi! between attributes in a
relation. $or e#am!le* 4A4 and 4B4 are attributes in relation ,. 4B4 is functionally de!endent on 4A4
IA BK if each value of 4A4 is associated with e#actly one value of 4B4.
The leftNhand side and the ri"htNhand side functional de!endency are sometimes called the
determinant and de!endent res!ectively.
A relation is in B9B$ if and only if every determinant is a 9andidate .ey.
The difference between the third normal form and B9B$ is that for a functional de!endency A B*
the third normal form allows this de!endency in a relation if 4B4 is a !rimaryN.ey attribute and 4A4
is not a 9ndidate .ey.
Fhere as in B9B$. 4A4 must be 9andidate Oey. Therefore B9B$ is a stron"er form of the third
normal form.
M,2DH9T I!rdS*!rdname*!riceK
MrdS+>!rodname*!rice
9HST2M/, IcustS*custname*custaddrK
9ustS+>custname*custaddr
2,D/, IordS*custSmordS*:ty*amtK
2rdS+>:ty*amt
The M,2DH9T scheme is in B9B$. Since the !rdS is a candidate .ey* similarly customer
schema is also in B9B$.
The schema 2,D/,* however is not in B9B$* because ordS is not a su!er .ey for 2,D/,* i.e.
we could have a !air of tu!les re!resentin" a sin"le ordS.
Fourth Normal Form (4NF)
Multi valued de!endencies are based on the conce!t of first normal form* which !rohibits
attributes havin" a set of values. f we have two or more multi valued inde!endent attributes in
the same relation* we "et into a situation where we have to re!eat every value of one of the
attributes* with every value of the other attributes to .ee! the relation state consistent* and to
maintain inde!endence amon" the attributes involved. This constraint is s!ecified by a Multi
valued de!endency.
Employee Decomposed relation to reduce redundancy
NAME PRO1ECT NAME PRO1ECT
A 9ric.et A Microsoft
A Music A 2racle
B Movie B ntel
B ,eadin" B Sybase

$ourth Bormal $orm I0B$K: The definition of 0B$ is violated when a relation has undesirable
multivolume de!endencies* and hence identify such relations and decom!ose into 0B$ relations.
Alternate definition: A B that holds over ,* one ofrelation , is said to be in 0B$ if for every
MAD A the followin" is true:
B A ItrivialK* or
AB E , or
A is a su!er .ey
The /m!loyee relation is not in 0B$ because of the non+trivial MADs I!ro1ect and hobby
attributes of em!loyee relation are inde!endent of each otherK and BAM/ is not a su!er .ey of
/MM72D//. To ma.e this relation into 0B$ you have to decom!ose /MM72D// to M,2T/9T
ABD @2BBD.
Q.6 Read the following case study thoroughly and answer the following questions:
Laxmi bank is one of the largest private sector banks of India. It has an extensive network
of more than 200 branches. It offers banking services to retail as well as corporate clients.
The bank faced a challenge in integrating multi-pronged database management system into
a centralized system. The IT department of the bank also realized that the computing
capabilities of its PCs and servers were not proportionately distributed among all its
branches. Each branch had its database management system stored in a traditional way on
the disk. The total cost of operating and maintaining the current IT infrastructure was very
high and the fundamental shortcomings added to the costs. Moreover, there were also
recurrent problems due to the malfunctioning of the currently operational database
management system. Therefore, the bank`s top management decided to fix the problem and
operationalise a robust database management system. The bank hired an external database
technology consulting firm called AKPY Info systems Limited. AKPY divided the entire IT
infrastructure of the bank around two verticals. The retail banking vertical and the
corporate banking vertical. All the individual database servers from the individual
branches were removed. The entire database system was made virtual such that the
managers and the staff can access only the required information (related to retail banking
BAM
/
M,2T/9T @2BBD
A Microsoft 9ric.et
A 2racle Music
A Microsoft Music
A 2racle 9ric.et
B BT/7 Movies
B Sybase ,eadin"
B BT/7 ,eadin"
B Sybase Movies
or corporate banking) from the respective centralised data centers. There were only two
such centralised data centers (one for retail banking and another for corporate banking)
that were managed centrally. Staff and managers could access the information through
their PCs and laptops. Centralised database management system complemented the
security system by bringing in authentication through a unified ID management server.
Managers and officers of the bank were able to process half a million transactions per
month in real time after the new implementation. There were significant savings in the cost
and also in the consumption of power. Now there were no problems with regard to
imbalances in the load across various network servers. Due to centralised data
management, top management could keep an eye on the functioning of various branches.
Hence the cases of fraud and cheating reduced considerably. The bank managers could also
process the loan applications in reduced time since the customer`s previous records could be
accessed at the click of the button and approval from the higher authorities could be
obtained in real time. Moreover the new system also brought in many applications that
helped local managers in the decision making process.
a. List the uses of centralized data management
b. What steps Laxmi bank need to take if it were to change its centralised database system
to a distributed database system in future?
Ans : a. uses of centralized data management :
$rom the above case study it is concluded that centrali3ed data mana"ement has followin"
advanta"es which has made it more useful than the older system :
1. 9entralised database mana"ement system com!lements the security system by brin"in"
in authentication throu"h a unified D mana"ement server
2 f data is stored and mana"ed in various locations* as the volume of data increases* time
and effort* as well as necessary devices to mana"e all the data must be increased
accordin"ly. f data is "athered at one location and centrally mana"ed* a lar"e s!ace and
time can be saved.
3 Data availability is not efficient.
0 The failure of central database will lead to loss of whole database.
' Due to the com!le#ity in the desi"n* it re:uires si"nificant !rocedures* very e#!erienced
DBAs and systems !eo!le.
U t will not su!!ort addition of new nodes due to the fre:uency.
8 t is easier to mana"e.
b. Data fragmentation
Data fra"mentation occurs when a collection of data in memory is bro.en u! into many !ieces
that are not close to"ether. t is ty!ically the result of attem!tin" to insert a lar"e ob1ect into
stora"e that has already suffered e#ternal fra"mentation.
$or e#am!le* files in a file system are usually mana"ed in units called bloc.s or clusters. Fhen a
file system is created* there is free s!ace to store file bloc.s to"ether conti"uously. This allows
for ra!id se:uential file reads and writes. @owever* as files are added* removed* and chan"ed in
si3e* the free s!ace becomes e#ternally fra"mented* leavin" only small holes in which to !lace
new data. Fhen a new file is written* or when an e#istin" file is e#tended* the o!eratin" system
!uts the new data in new non+conti"uous data bloc.s to fit into the available holes. The new data
bloc.s are necessarily scattered* slowin" access due to see. time and rotational latency of the
readVwrite head* and incurrin" additional overhead to mana"e additional locations. This is called
file system fra"mentation.
Data replication
Active Ireal+timeK stora"e re!lication is usually im!lemented by distributin" u!dates of a bloc.
device to several !hysical hard dis.s. This way* any file system su!!orted by the o!eratin"
system can be re!licated without modification* as the file system code wor.s on a level above the
bloc. device driver layer. t is im!lemented either in hardware Iin a dis. array controllerK or in
software Iin a device driverK.
The most basic method is dis. mirrorin"* ty!ical for locally+connected dis.s. The stora"e industry
narrows the definitions* so mirrorin" is a local Ishort+distanceK o!eration. A re!lication is
e#tendable across a com!uter networ.* so the dis.s can be located in !hysically distant locations*
and the master+slave database re!lication model is usually a!!lied. The !ur!ose of re!lication is
to !revent dama"e from failures or disasters that may occur in one location* or in case such events
do occur* im!rove the ability to recover. $or re!lication* latency is the .ey factor because it
determines either how far a!art the sites can be or the ty!e of re!lication that can be em!loyed.
Data allocation
Data allocation may be decided by usin" com!uter !ro"rams a!!lied to a s!ecific domain to
automatically and dynamically distribute resources to a!!licants.
This is es!ecially common in electronic devices dedicated to routin" and communication. $or
e#am!le* channel allocation in wireless communication may be decided by a base transceiver
station usin" an a!!ro!riate al"orithm.
c. yes. t is !ossible to re!licate the centrali3ed database mana"ement model of the ban. in a
manufacturin" concern. As the code can be used a"ain and a"ain with some smaller
chan"es or modifications. t is one of the benefits of central data mana"ement that a
source code can be used a"ain and a"ain .nown as Software reuse.

You might also like