You are on page 1of 7

Homework 3

Annexure

Homework type/no: Online/Third Course code: CSE-301


Course instructor: Chavi Mam Course tutor:
Date of allotment: Date of submission: 28-10-10
Student roll no: RC2801B48 Section no: C2801

Declaration:
I declare that this assignment is my individual work. I have not copied from any other
student’s work or from any other source except where due acknowledgment is made
explicitly in the text, nor has been written for me another person.
Student’s signature:
Yogesh Gandhi
Evaluator’s comments:
Marks obtained _____________________ out of
______________________________
Content of home work should start from this page only:

PART-A
Question 1: Can we achieve 2NF without 1NF. Also differentiate 1NF and 2NF
with an example.
Answer: Normalization is the process of efficiently organizing data in a database.
There are two goals of the normalization process: eliminating redundant data and
ensuring data dependencies make sense. Both of these are worthy goals as they reduce
the amount of space a database consumes and ensure that data is logically stored. No
we can’t achieve 2NF without 1NF because when a relation is in 1NF then it is atomic
i.e. only one value is associated with each attribute and the value is not a set of values
then only we are able to identify a primary key and all the non-primary key attribute in
a relation are fully functionally dependent on the primary key.

 The following table is not in 1NF


Department NO M_NO EMPLOYE_NO EMPLOYE_NAME

D101 12345 20000 ADI


TUSHAR
20001
RAVI
20002

D102 13456 30000 YOGESH


30001 PANKAJ

Table in 1NF

DPT_NO MG_NO EMP_NO EMPLOYE_NAME


D101 12345 20000 ADI

D101 12345 20001 TUSHAR

D101 12345 20002 RAVI

D102 13456 30000 YOGESH

D102 13456 PANKAJ


30001
2NF EXAMPLE:

Inventory

Description Supplier Cost Supplier Address

Here, Cost is fully, functionally dependent upon the ENTIRE PK (Description-


Supplier) for its existence. Therefore, Supplier Address is NOT functionally
dependent upon the ENTIRE PK (Description-Supplier) for its existence.

Inventory

Description Supplier Cost

Supplier

Name Supplier Address

The above relation is now in 2NF

Question 2:- How is the concept of functional dependency associated with the
process of normalization?

Answer:-

Normalization is based on the concept of dependencies between the attributes of a


table. If more than one attributes of a single relation have relationships then this is
termed as functional dependency because one attributes depends on the other for
providing complete detail. It is associated with the normalization because
normalization is a technique that is used to remove these functional dependencies in
order to represent the information in simple way or in shape of tables.

A functional dependency occurs between two attributes in a database, A and B, if


there exists a relationship such that for each value of A there is only one
corresponding value of B (A -> B). This can be extended to a functional dependency
where A may be a set of tuples (x, y, z) that correspond to a single value B ([x, y, z]
-> B). In simple mathematical terms the functional dependency must pass the vertical
line test for proper functions.
Normalizing a database requires analysis of the closure of the set of functional
dependencies to ensure that the set complies with the rules for the given normal form.
If the table does not comply with the rules then the table is split following specific
procedures to achieve the desired normal form. Every table in a database has a normal
form and to make a statement that a database is in a certain normal form (ex. 3NF)
means that every table complies with the rules for 3NF.

he term functional dependency and functional dependency are used interchangeably


in the literature. We may use example the shipment, one that includes the usual
attributes S#, P#, QTY and City
S# CITY P# QTY
S1 Delhi P1 100
S1 Delhi P2 100
S2 Mumbai P1 200
S2 Mumbai P2 200
S3 Mumbai P2 300
S4 Delhi P2 400
S4 Delhi P4 400
S4 Delhi P5 400

Let r be a relation, and let X and Y be arbitrary subsets of the set of attributes of r.
Then we say that Y is a Functional dependent of X in symbols.

XY

If and only if each X value in r has associated with it precisely one y value in r. In
other words, whenever two tuples or r agree on their X value, they also agree on their
Y values.For example the relation shown in figure satisfied the functional
dependency{S#{CITY}because every tuple of the relation with a given S# value also
has the same CITY value.A functional dependency is a many-to-one relationship
between two sets of attributes of a given relvar. Given a relvar R, the functional
dependency AB is said to hold for R if and only if, whenever two tuples of R have
the same value for A, they also have the same value for B

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


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

Because
A->CD and F->A
And
also F->CD and F->DE

So
that F->D

Therefore
the relation R2(A,F,D) is a correct decomposition.

And
also F->E so we can make the relation R3(E,F).

Now
the remaining attributes A,B,C and B->C , so there is another relation form
that is R1(A,B,C).

So all
the three decomposition of relation R in R1, R2 and R3 are correct according to
the rule of functio0nal dependency.

PART-B

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

ANS: Partially Committe


committed d

Active

Failed Aborted

When a transaction starts its execution, it enters the active state. When transaction is
its last statement it moves from active state to partially committed state. On the
successful execution of the transaction, it moves from partially committed state to
committed state. But if some failure occurs in active or partially committed state then
the transaction enters the fail state. A failed transaction then rolled back and it enters
the aborted state.
There are two options for aborted transaction and they are:
1. An aborted transaction can be restarted if it was aborted as a result of some
hardware or software error.
2. An aborted transaction can be killed by the system if it was aborted as a result
of some internal logical error which can be corrected only by rewriting the application
program.

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


example.
Answer:
The comparisons between conflict and serializibility a (possibly concurrent) schedule
is serializable if it is equivalent to a serial schedule. Different forms of schedule
equivalence give rise to the notions of:
1. Conflict serializability
2. View serializability

1. Conflict serializability:- Instructions li and lj of transactions Ti and Tj respectively,


Conflict if and only if there exists some item Q accessedby both li and lj, and at least
one of these instructionswrote Q Intuitively, a conflict between li and lj forces a
(logical)temporal order between them. If li and lj are consecutivein a schedule and
they do not conflict, their results wouldremain the same even if they had been
interchanged inthe schedule.

2. view serializability:- Let S and S´ be two schedules with the same set of
transactions.S and S´ are view equivalentif the following three conditions are met:
1. For each data item Q, if transaction Ti reads the initial valueof Q in schedule S,
then transaction Ti must, in schedule S´,also read the initial value of Q.
2. For each data item Q if transaction Ti executes read(Q) inschedule S, and that
value was produced by transaction Tj(if any), then transaction Ti must in schedule S´
also read thevalue of Q that was produced by transaction Tj .
3. For each data item Q, the transaction (if any) that performs the final write(Q)
operation in schedule S must perform thefinal write(Q) operation in schedule S´.

(Example)

1. T3 | T4 | T6
2. read3(Q) | |
3. | write4(Q) |
4. write3(Q) | |
5. | | write6(Q)

Sm: r3(Q); w4(Q); w3(Q); w6(Q); c1; c2; c3;

This schedule is view serializable. It is view equivalent to the serial schedule <T3,
T4, T6>, since one read(Q) instruction reads the initial value of Q in both
schedules, and T6 performs the final write of Q in both schedules.
Question 6:- Are the ACID properties of a transaction essential to ensure the
integrity of data? Give an example of each property.
Answer:
The ACID properties of a transaction essential to ensure the integrity of data
AtomicityAtomicity. . Either all operations of the transaction are properly reflected in
the database or none arereflected are
Ex:-
1 Read(A);
2 A-50;
3 Write(A);
4 Read(B)
5 B+50;
6 Write(B);
Consistency:-Execution of a transaction in isolation preserves theconsistency of the
database
Ex:
Consistency requirement ––the sum of A and B is unchanged by the execution of the
transaction.
Isolation:-. Although multiple transactions may execute concurrently, each transaction
must be unaware of other concurrently executing transactions. Intermediate
transaction results must be hidden from other concurrently executed transactions
Ex:
Once the user has been notified that the transaction has completed (i.e., the transfer of
the $50 hasthe hastaken place), the updates to the database by the transaction taken
must persist despite failuresmust failures

Durability:-After a transaction completes successfully, the changes it has made to the


database persist, even if there are system failures.
Ex:
if between steps 3 and 6, another transaction is allowed to access the partially updated
database, it will see an inconsistent database (the sum A + B will be less than it should
be). B

You might also like