Вы находитесь на странице: 1из 6

LOVELY PROFESSIONAL UNIVERSITY

MODEL HOME WORK: 3

School: LSTCA
Depar
tment:CSE/IT

Name of the faculty member: Geetika Mam

Course No: CSE301

Course Title: Database Management System

Name : Amit Ranjan

Section: E1802A22

Date of Submission: March 31,2011


Que 1: Can we achieve 2NF without 1NF. Also differentiate 1NF and 2NF with an example?

Ans1-: No we Can’t achieve 2NF without the 1NF. For 2NF we must have all the attributes in first
normal form and non key attributes are fully dependent on primary key attributes.

1NF -: For a relation to be in 1NF we have the following conditions-:

1) All the primary key attributes are defined


2) Each row and column contain only one and one value ,not a set of values.
3) All the attributes subject and are dependent on primary key
For example we have a student table with attributes (rollno, name ,record(Subject,marks)). The
data in the student table is not in normalized form because the attribute record contain multiple
values. We can can covert it into normalized form i.e in 1NF form. By reducing non atomic values
of subject and marks. We can reduce the it into 1NF by making rec_subjects and rec_marks as
seprate attributes in a table . Then it will not contain any non atomic values and it is said to be in
normalized form i.e 1NF. The combination of (roll no, rec_subjects) forming composite key.

2NF-: For a relation to be in second normal form we have the following conditions-

1) All the attributes must be in 1NF.


2) All the non attributes should be fully dependent upon primary key.
For example taking a relation named order-

Order_no B_name Quantity B_price

4200 Learn c 15 Rs.173

4200 Database 20 Rs.123

4100 IT 30 Rs.200

4500 Learn c 50 Rs.173

4400 Database 15 Rs. 123

Here in this example (order_no,b_name ) act as the composite key i.e the primary key. So the
attribute quantity is determined by the combination of these two attributes . B_price can be
detrmined with the only attribute B_name. So in the 2NF we can divide the following table into
two tables showing functional dependency.

Q u e s t i o n 2 : How is the concept of functional dependency associated with the process


of normalization?
Ans2-: Any attribute in the relation is functionally dependent upon other if each value of
one attributei s a s s o c i a t e d w i t h o n l y o n e v a l u e o f o t h e r a t t r i b u t e i n a
relation.

Following are the reasons-:

1) For the 2NF all the non key attributes should be fully functionally dependent on
primary key of the relation.

The example given in the above question explains the concept of functional dependency in the
2NF. Inthis way functional dependency is fully associated with the process of
normalization i.e it helps inderiving first three normal forms of normalization.

Question 3: A relation R (A, B, C, D, E, F) have the following set of dependency:A->CD; B-


>C; F->DE ;F->AIs the decomposition of R in R1 (A, B, C,), R2 (A, F, D) and R3 (E, F)
dependency reversing?

Ans 3- : In the relation R , A determines the combination of Attributes of C D , B


determin es C ,Fdetermines DE and F determines A also. No the the decomposition of R into
R1,R2,R3 will not results in dependency reversing. It will results into the 2nd
normalization form and 3rd normalization forms of the relation i.e it will provide 2NF and 3NF
forms.

Question 4: Draw the state diagram showing various states of a transaction. Also give the
workingof this diagram.

Ans4-: Following are the five states of transactions-:


1) Active-:It is the state when the first operation of the transaction starts executing .
This stateremains active until till all the operation ends.
2) Partially commited-: T h i s i s t h e s t a t e c o m e s w h e n a l l t h e o p e r a t i o n a r e
c o m p l e t e d a n d transaction moved to the commit state.
3) Failed-: This is the state when the transaction stops because of some errors. If it fails then it
getsrollback and enters the other state.
4) Aborted-: this is the state occurs When the transaction is rolled back and the database
restoresback to original postion.
5) Commited-: This is the state occurs when all the operation are performed and data
completedsaved to database.
Parti
aly
com
com
mite
mite
d
d

Acti
ve
abo
fail
rted
ed

Question 5: Make a comparison between conflict and view serializability with an example.

Ans5-: Serializibility is the concept which helps in understanding the non serial schedule which is
causing problems and which has same results as that of the transactions which are part of the
schedule.

Conflict Serializibilty-: A schedule is said to be conflict serializible if it is conflict equivalent to


a serial schedule consider the following example in the schedule S1 the write(a) operation of T1
conflicts with the read(a) operation of T2 but the read operation of T1 doesn’t conflict with the
Write(a) operation of T2 because former both the operation with the same data A and one of them
is write operation and in later case the two operations operating on different data items. So if we
swap the order of non conflicting operations i.e read(b) of transaction T1 with write(a) of
transaction T2 , we get a new schedule S2. S1 and S3 are conflict equivalent as schedule S1 can
be transferred into Schedule S3 By series of swaps to schedule S1.

S1 S2 S3

T1 T2 T1 T2 T1 T2

Read(a) Read(a) Read(a)

Write(a) Write(a) Write(a)

Read(a) Read(a) Read(b)


Read(b)
Write(a) Write(b)
Read(b) Write(a) Read(a)

Write(b) Write(b) Write(a)

Read(b) Read(b) Read(b)

Write(b) Write(b) Write(b)

View Serializibility-: A schedule is said to be view serializible if it is view equivalent to serial


schedule. Consider the following example-:

S1 S2 S3

T1 T2 T1 T2 T1 T2

Read(a) Read(a) Read(a)

A=A-100 T=A*0.2 A=A-100

Write(a) A=A-T Write(a)

Read(b) Write(a) Read(a)

B=B+100 Read(b) T=A*0.2

Write(b) B=B+T A=A-T

Read(a) Write(b) Write(a)

T=A*02 Read(a) Read(b)

A=A-T A=A-100 B=B+100


Write(b)
Write(a) Write(a)
Read(b)
Read(b) Read(b)
B=B+T
B=B+100
Write(B)
Write(b)
Schedule S1 and S3 are view Equivalent because the values of data item A and B read by
transaction T2 was produced by T1 in both the schedules. This shows the concept of view
serializibility.

Question 6: Are the ACID properties of a transaction essential to ensure the


integrity of data?Give an example of each property.

Ans6-:Yes , the ACID properties of transactions are essential to ensure the integrity of data.
Following are the properties-
1)Atomicity-: It means that the whether all the changes are made to transaction and no change is
made. For example we have two accounts A and B we want to transfer money from
account A to B.This means money is to be subtracted from account A and added to account B.
A c c o r d i n g t o t h i s property both these operations made simultaneously or none is made.

2)Isolation-: This means that when the two users are using same database the changes
will bemade both of them concurrently i.e the data used during the execution of one transaction
cannot be usedby the other transaction until the first one is completed.

=========================

Вам также может понравиться