You are on page 1of 13

Q.

Consider the following database relation. ClientREntal (ClientNo, propertyNo, CName, pAddress, renstart, rentFinish, rent, ownerNo, Oname) With the following functional dependencies clientNo, propertNorenstart, rentFinish clientNoCname, propertyNo pAddressm rent, ownerNo, Oname with the PrimaryKey (clientNo, PropertyNo) Find the normal form in which the relation clientRental is.

Ans. In the database relation client_rental we have primary key {client_no, property_no} while the partial dependencies such as client_noCname and property_nopaddres, rent, ownerno, oName. So it can not be in second normal form and its in 1NF. Q.2 For the following record type, tell whether it is in Third Normal Form or Not : EMPLOYEE (Employee-Code, Employee-name, Department, Salary, Project-No., Termination-Date-of-project) where each ProjectNo. has unique Termination-data-of-project. Justify your answer, if it is in Third Normal Form. If it is not in Third Normal Form, bring it into Third Normal Form through Normalization. (Jan. 2001) Ans.The above given relation is not in Third Normal Form. The properties of a relation to be in Third Normal Form can be enlisted as follows : A relation R is in third normal form (3NF) if and only if it is in 2NF and every nonkey attribute is nontransitively dependent on the primary key : In the given relation the Key can be Employee-Code. The Employee-name, Department, Salary and Project-No are dependent on the Employee-Code, but the Termination-data-of-project which is a non key attribute is dependent of Project-no which is not a key attribute. Hence the non key attribute is dependent of another non key attribute which is against the norms of the Third Normal Form.

The given relation can be decomposed into two relations namely Employee and Project. The schema for theses relations can be shown as follows : EMPLOYEE(Employee-Code, Employee-name, Department, Salary, Project-No.) PROJECT(Project-No., Termination-Date-of-project) Now the key attribute for EMPLOYEE relation can be Employee-code and all the rest non key attributes are functionally dependent on this key. In case of the PROJECT relation the key attribute is Project-No and the non key attribute Termination-Date-of-project is dependent on the key Project-No. The functional dependency diagram can be shown as follows :
Project-No Termination-data-of-project Employee-Name Department Employee-Code Salary Project-No

Q.3 Is the following relation in Third Normal Form ? Roll No. Name Department Yea Hostel r Name 2101 Raman Physics I Ganga 2102 Krishan Chemistry I Ganga 2103 Abdul Mathematics II Kaveri 2104 John Botany II Kaveri Justify your answer, if it is in Third Normal Form. If it is not, then bring in Third Normal Form. (June 2001) Ans.The above given relation is not in Third Normal Form. The properties of a relation to be in Third Normal Form is as follows : A relation R is in third normal form (3NF) if and only if it is in 2NF and every nonkey attribute is nontransitively dependent on the primary key. In the above relation the Primary Key is Roll No. The Name, Department, year is dependent on Roll no. But the Hostel name is dependent on Year which not a key. Hence there is problems in non transitively dependency. The above relation can further be decomposed in to two relation namely Student and Hostel relation. This decomposition can be shown as follows : STUDENT Roll Name No. 2101 Raman 2102 Krishan 2103 Abdul 2104 HOSTEL Year I I Hostel Name Ganga Ganga John Departmen t Physics Chemistry Mathematic s Botany Year I I II II

II Kaveri II Kaveri Note : Here is it assumed that the student is having unique department. Otherwise one more relation department can be constructed. Q.4 List all the functional dependencies and multivalued dependencies satisfied by the relation of the figure given below: (June 2002) A B C D a1 b1 C1 d1 a1 b2 C1 d2 a2 b2 C2 d2 a2 b3 C2 d3 a3 b3 C2 d3 Ans.Functional dependency shows that one set of attributes are dependent on one attribute which may be single or composite. If X and Y are two attributes of a relation and Y is dependent on X then it can be shown as follows :
X Y

The multi valued dependency can be shown as


X Y

In the given relation the functional and multi-valued dependencies can be shown as follows :
A AB A A C C B D

Q.5 Consider the relation R with 5 attributes A, B, C, D, E. You are given the following dependencies: A B BC E ED A (i) List all keys of R. (ii) Is R in 3NF or BCNF Ans.(ACD)+ = ABCDE = R (BCD)+ = BCDEA (DC)+ = EDABC (i) Keys = ACD, BCD, CDE (ii) R is in 3NF Q.6 Consider the relation R which has attributes that hold schedules of courses and sections at a university; R = { Course No., Section No., Offering_dept, Credit hrs, Course level, Semester, Instructor SSN, Year, Days_hrs, Room No., No. of students } Suppose that the following functional dependencies hold on R {Course no.} {Offering dept, Credit hrs, Course level} {Course No., Section No., Semester, Year} {Days_hrs, Room No., No. of Students, Instructor SSN} {Room No., Days_hrs, Semester, Year} {Instructor SSN, Course No., Section No.} (i) Which sets of attributes from keys of R? (ii)Show how you would normalize the relation above. Also give the final tables.

Ans. F1: {Course no.} {Offering dept, Credit hrs, Course level} F2: {Course No., Section No., Semester, Year} {Days_hrs, Room No., No. of Students, Instructor SSN} F3: {Room No., Days_hrs, Semester, Year} {Instructor SSN, Course No., Section No.} (i) Keys: (1) {Course No., Section No., Semester, Year} (2) {Semester, Year, Days_hrs, Room No.} (ii) 2NF: R1 (Course No., Offering dept, Credit hrs, Course level) R2 (Course No., Section No., Semester, Year, Days_hrs, Room No., No. of Students, Instructor SSN)

3NF: above relation is in 3NF Q.7 Normalize the following table to 3NF. Id_No 2010 2050 3015 3020 4005 5010 Name Department Course Harjee Chemistry BSc Arshdeep Physics BSc Simran Mathetmaics MA Mukti Pawan Lovleen English Punjabi Computer Sc MA BA BCA Hostel Block-I Block-I BlockIII BlockIII BlockII BlockIV

Ans. Given Relation R has following set of Functional Dependencies F = {Id_no Name, Department} Course Hostel, Hostel Course, Id_no. Course } Key for the Relation R : {Id_no} Definition of 2NF : A Relation is in 2NF if each Functional Dependency is Full Functional Dependency. Now, in this Relation key is single key (Id_no.) So, Relation is in 2NF Definition of 3NF : If the relation is in 2NF and each of the Functional Dependency. Functional Dependency should satisfy any of following condition : 1. It is Trivial Functional Dependency. 2. For Functional Dependency, is key. 3. For functional dependency, is prime attribute. In brief, it is said if relation does not have Transitive Functional dependency between any non-key attribute, then the relation is not in 3NF. Now, check following dependency
Id-no. Name Department

Course

Hostel

Here, mutual dependency between two non-key attributes course and Hostel have been observed. So, this relation is not in 3NF. Functional Dependency : Id_no Name, Department, course Satisf. rule 2 : Id_no. is key Functional Dependency Course Hostel does not satisfy any rule It violates definition of 3NF So, we can say this relation is not in 3NF. Decomposition of R for 3NF : R1 (Course, Hostel) F1 = {Course Hostel} R2 (Id_no., Name, Department, course} with F2 = Id_no. {Name, Department, Id_no. Course} Q.8 Examine the table shown below : Staff No. E101 Branch No. B02 Branch Address Name Positio Hrs/We n ek Ram Assist 16 ant Ram Assist 9 ant Moha Assist 14 n ant Moha Assist 10 n ant

Sun Plaza, Delhi, 110001 E101 B04 2/3 UT, Delhi, 110111 E122 B02 Sun Plaza, Delhi, 110001 E122 B04 2/3 UT, Delhi, 110111 (i) Why is the table above not in 2NF ? (ii)Describe the process of normalizing the data shown in the table above to third normal form (3NF). (iii) Identify the primary and foreign keys in your 3NF relations. Ans. Given Relation has following Functional Dependency Set F : F = { {Staff_No,Branch_No} Hrs_worked ,

Staff_No {Name, Position} , Branch_No Branch_add } Key of the Relation is composite key (Staff, Branch_No). Second Normal Form (2NF) : A relation R is in second normal form (2NF) if and only if it is in 1NF and every non key attribute is fully functionally dependent on the primary key. In this relation, F.D. {Staff_No,Branch_No} Hrs_worked is Full Functional dependency ; While F.D. Staff_No {Name, Position} , Branch_No Branch_add are Partial Functional Dependency. So, The relation is not in 2NF. Decomposition to 2NF : R1 (Staff_No, Name, Position) with F1 = {Staff_No, Name, Position) R2 (Branch_No, Branch_add) with F2 = { Branch_No Branch_add ) R3 (Staff_No, Branch_No, Hrs_worked ) with F3 {{Staff_No,Branch_No} Hrs_worked } Third Normal Form (3NF) : A relation R is in third normal form (3NF) if and only if it is in 2NF and every non key attribute is non-transitively dependent on the primary key : Relations R1, R2, and R3 are in 2NF; and every non key attribute of these relations are non-transitively dependent on the primary key. So, Relations R1, R2, and R3 are in 3NF. Relation R1 : Primary Key : Staff_No Foreign Key : R3(Staff_No) Relation R2 : Primary Key : Branch_No Foreign Key : R3(Branch_No) Relation R3: Primary Key : Staff_No, Branch_No Foreign Key : NIL

Q.9 Explain why Project-Join Normal form is more desirable than 4NF. OR Define 4NF Explain through an example relation which does not satisfy 4NF and decompose the relation into a set relation which do satisfy 4NF. What advantages are gained by this decomposition? OR Explain why Project-Join Normal Form is more desirable than 4NF. Ans.Consider a Relation SPJ from the supplier-parts-projects database. The Sample data is given in Fig. 1 The relation SPJ is all key and does not involve any nontrivial FDs or MVDs at all, that means it is in 4NF.

SPJ (Original relvar)

Decomposed relations Join over P# Join over J#, S#

Original SPJ

S # S 1 S 1 S 2 S 1

P # P 1 P 2 P 1 P 1

J # J 2 J 1 J 1 J 1

S P

S # S 1 S 1 S 2

P P P # J # P P 1 1 P P 2 2 P P 1 1

J # J 2 J 1 J 1

JS

J # J 2 J 1 J 1

S # S 1 S 1 S 2

S # S 1 S 1 S 2 S 2 S 1 two

P # P 1 P 2 P 1 P 1 P 1

J # J 2 J 1 J 1 J 2 J 1

Fig. 1 Relation SPJ is the join of all three of its binary projections but not any Fig.1 depicts The three binary projections Sp, PJ, and JS corresponding to the SPJ relation . The effect of joining the SP and PJ projection (over P#). The effect of joining of joining result of SP and PJ with JS Projection (over J# and S#). Problems / anomalies : Join of SP and PJ projection over P# give the same attributes as relation SPJ, But it gives an undesirable (spurious / additional) attributes.

If (S2, P1, J1) is inserted, (S1, P1, J1) must also be inserted. That means, Insert (S2, P1, J1) tuple by (S2, P1) in SP and (P1, J1) in PJ relation. And join of this two relation SP and PJ will give one more spurious tuple (S1, P1, J1). If(S1,P1, J1) deleted , another tuple must also be deleted That means, If we would like to delete a tuple (S1, P1, J1) we have to delete SP and PJ projections on this tuple from SP and PJ relation respectively. Delete tuple (S1, P1) in SP and (P1, J1) in PJ relation. And join of this two relation SP and PJ will give loss data. It will remove other tuples (S1, P1, J2) and (S1,P1, J1) also. Join of SP and PJ projection over P# give the same attributes as relation SPJ, But it gives an undesirable (spurious / additional) attributes. While the joining of all the decomposed relation give the original relation SPJ. This example sets new constraint JD on a relation. This JD constraint is known as a join dependency. A JD is a constraint on the relation concerned, just as MVD or FD is a constraint on the relation concerned. We can define JD as Join Dependency: Let R be a relvar, and let A, B, ...Z be subsets of the attributes of R. Then we say that R satisfies the JD. * { A, B, ...., Z } If and only if every possible legal value of R is equal to the join of its projections on A, B, ..., Z. R(A, B, C) satisfies the JD *{AB, AC} if and only if it satisfies the MVDs A B | C. Since this theorem can be taken as definition of multi-valued dependency, it follows that an MVD is just a special case of a JD, or(equivalently) that JDs are a generalization of MVDs. Formally, we have A B | C * { AB, BC }

Fifth Normal Form : A revar R is in 5NF also called projection-join normal form (PJ / NF) if and only if every nontrivial * join dependency that holds R is implied by candidate keys of R.

Where, Trivial Dependency : The JD * {A, B, ..., Z} is trivial if and only if one of the projections A, B, ...., Z is the identity projection of R (i.e. the projection over all attributes of R) Note : Any relvar can be nonloss-decomposed into an equivalent collection of 5NF relvars; 5NF is always achivable. 5NF is guaranteed to be free of anomolies that can be eliminated by taking projections. city.