Relational Design Theory

Size: px
Start display at page:

Download "Relational Design Theory"

Transcription

1 OpenStax-CNX module: m Relational Design Theory Nguyen Kim Anh This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract One important theory developed for the relational model involves the notion of functional dependency (fd ). Like constraints functional dependencies are drawn from the semantics of the application domain. Essentially, fd 's describe how individual attributes are related. Functional dependencies are a kind of constraint among attributes within a relation and that have implications for "good" relational schema design In this lecture, we will study basic theory and denition of functional dependencies methodology for improving schema designs (normalisation) 1 Relational Design Theory One important theory developed for the relational model involves the notion of functional dependency (fd ). Like constraints functional dependencies are drawn from the semantics of the application domain. Essentially, fd 's describe how individual attributes are related. Functional dependencies are a kind of constraint among attributes within a relation and that have implications for "good" relational schema design In this lecture, we will study basic theory and denition of functional dependencies methodology for improving schema designs (normalisation) The aim of studying this: improve understanding of relationships among data gain enough formalism to assist practical database design 2 Relational Design and Redundancy Generally, a good relational database design must capture all of the necessary attributes/associations and should do this with a minimal amount of stored information (it means there is no redundant data) In database design, redundancy is generally a "bad thing" because it causes problems maintaining consistency after updates However, it can sometimes lead to performance improvements e.g. may be able to avoid a join to collect bits of data together Version 1.1: Jul 8, :34 am

2 OpenStax-CNX module: m Consider the following relation dening bank accounts/branches: accountno balance customer branch address assets A Downtown Brooklyn A Perryridge Horseneck A Round Hill Horseneck A Brighton Brooklyn A Mianus Horseneck A Redwood Palo Alto A Round Hill Horseneck Table 1 Insertion anomaly: when we insert a new record, we need to check that branch data is consistent with existing tuples Update anomaly: if a branch changes address, we need to update all tuples referring to that branch Deletion anomaly: if we remove information about the last account at a branch, all of the branch information disappears Insertion anomaly example (insert account A-306 at Round Hill): accountno balance customer branch address assets A Downtown Brooklyn A Perryridge Horseneck A Round Hill Horseneck A Brighton Brooklyn A Mianus Horseneck A Redwood Palo Alto A Round Hill Horseneck A Round Hill Horseneck Table 2 Update anomaly example (update Round Hill branch address):

3 OpenStax-CNX module: m accountno balance customer branch address assets A Downtown Brooklyn A Perryridge Horseneck A Round Hill Palo Alto A Brighton Brooklyn A Mianus Horseneck A Redwood Palo Alto A Round Hill Horseneck Table 3 Deletion anomaly example (remove account A-101): accountno balance customer branch address assets A Downtown Brooklyn A Perryridge Horseneck A Round Hill Horseneck A Brighton Brooklyn A Mianus Horseneck A Redwood Palo Alto A Round Hill Horseneck Table 4 Problem is after deleting the tuple, we don't know where is the Downtown branch located or what are its assets? To avoid these kinds of update problems we need to decompose the relation U into several smaller relations Ri where each Ri has minimal overlap with other Rj. Typically, each Ri contains information about one entity (e.g. branch, customer,...) This leads to a (bottom-up) database design procedure: start from an unstructured collection of attributes use normalisation (via fds) to impose structure nal schema is a collection of tables nal schema has minimal redundancy (normalised) This contrasts with our earlier (top-down) design procedure: structure data at conceptual level (ER design) then map to "physical" level (relational design) nal schema is a collection of tables It appears that ER-design-then-relational-mapping leads to a collection of well-structured tables which is similar to a normalised schema

4 OpenStax-CNX module: m However, we still need a dependency theory and normalisation procedure to deal with redundancy because of some reasons 1. ER design does not guarantee minimal redundancy dependency theory allows us to check designs for residual problems 2. Normalisation can be viewed as (semi)automated design determine all of the attributes in the problem domain collect them all together in a "super-relation" (with update anomalies) provide information about how attributes are related apply normalisation to decompose into non-redundant relations 2.1 Notation/Terminology Most texts adopt the following terminology: Relation schemas upper-case letters, denoting set of all attributes (e.g. R, S, P, Q ) Relation instances lower-case letter corresponding to schema (e.g. r(r), s(s), p(p), q(q) ) Tuples Lower-case letters (e.g. t, t', t1, u, v ) Attributes Upper-case letters from start of alphabet (e.g. A, B, C, D ) Sets ofattributes simple concatenation of attribute names (e.g. X=ABCD, Y=EFG ) Attributes in tuples tuple[attrset] (e.g t[abcd], t[x]) Table 5 3 Functional Dependency A relation instance r(r) satises a dependency X Y if for any t, u r, t[x] = u[x] t[y] = u[y] In other words, if two tuples in r agree in their values for the set of attributes X, then they must also agree in their values for the set of attributes Y. We say that "Y is functionally dependent on X". Attribute sets X and Y may overlap; trivially true that X X. Consider the following instance r(r) of the relation schema R(ABCDE): A B C D E a1 b1 c1 d1 e1 a2 b1 C2 d2 e1 a3 b2 C1 d1 e1 a4 b2 C2 d2 e1 a5 b3 C3 d1 e1 Table 6

5 OpenStax-CNX module: m What kind of dependencies can we observe among the attributes in r(r)? Since the values of A are unique, it follows from the fd denition that: A B, A C, A D, A E It also follows that A BC (or any other subset of ABCDE). This can be summarised as A BCDE From our understanding of primary keys, A is a Primary Key. Since the values of E are always the same, it follows that: A E, B E, C E, D E Note: cannot generally summarise above by ABCD E In general, A Y, B Y AB Y Other observations: combinations of BC are unique, therefore BC ADE combinations of BD are unique, therefore BD ACE if C values match, so do D values, therefore C D however, D values don't determine C values, so D C We could derive many other dependencies, e.g. AE BC,... In practice, choose a minimal set of fds (basis) from which all other fds can be derived which typically captures useful problem-domain information 3.1 Inference Rule Armstrong's rules are complete, general rules of inference on fds. F1. Reexivity e.g. If Y X then X Y a formal statement of trivial dependencies; useful for derivations F2. Augmentation e.g. X Y XZ YZ if a dependency holds, then we can freely expand its left hand side F3. Transitivity e.g. X Y, Y Z X Z the "most powerful" inference rule; useful in multi-step derivations While Armstrong's rules are complete, other useful rules exist: F4. Additivity e.g. X Y, X Z X YZ useful for constructing new right hand sides of fds (also called union) F5. Projectivity e.g. X YZ X Y, X Z useful for reducing right hand sides of fds (also called decomposition) F6. Pseudotransitivity e.g. X Y, YZ W XZ W shorthand for a common transitivity derivation

6 OpenStax-CNX module: m Using rules and a set F of given fds, we can determine what other fds hold. Example (derivation of AB GH): R = ABCDEFGHIJ F = { AB E, AG J, BE I, E G, GI H } 1. AB E (given) 2. AB AB (using F1) 3. AB B (using F5 on 2) 4. AB BE (using F4 on 1,3) 5. BE I (given) 6. AB I (using F3 on 4,5) 7. E G (given) 8. AB G (using F3 on 1,7) 9. AB GI (using F4 on 6,8) 10. GI H (given) 11. AB H (using F3 on 6,8) 12. GI GI (using F1) 13. GI I (using F5 on 12) 14. AB GH (using F4 on 8,11) Table Closures 1. Closure of a set of dependencies The largest collection of dependencies that can be derived from F is called the closure of F and is denoted F+. Closures allow us to answer two interesting questions: is a particular dependency X Y derivable from F? are two sets of dependencies F and G equivalent? For the question "is X Y derivable from F?"... compute the closure F+; check whether (X Y ) F + For the question "are F and G equivalent?"... compute closures F+ and G+; check whether they're equal Unfortunately, closures on even small sets of functional dependencies can be very large. Algorithms based on F+ rapidly become infeasible. Example (of fd closure): R = ABC, F = { AB C, C B } F+ = { A A, AB A, AC A, AB B, BC B, ABC B, C C, AC C, BC C, ABC C, AB AB,......, AB ABC, AB ABC, C B, C BC, AC B, AC AB }

7 OpenStax-CNX module: m Closure of a set of attributes Given a set X of attributes and a set F of fds, the largest set of attributes that can be derived from X using F, is called the closure of X (denoted X+). We can prove (using additivity) that (X Y ) F + i Y X +. For computation, X+ is bounded by the number of attributes. For the question "is X Y derivable from F?"... compute the closure X+, check whether Y X + For the question "are F and G equivalent?"... for each dependency in G, check whether derivable from F for each dependency in F, check whether derivable from G if true for all, then F G and G F which implies F+ = G+ Algorithm to compute the closure of set of attributes Inputs: set F of fds set X of attributes Output: closure of X (i.e. X+) X+ = X stillchanging = true; while (stillchanging) { stillchanging = false; for each W -> Z in F { if (W in or equal X+) and not (Z in or equal X+) { X+ = X+ union Z stillchanging = true; } } } Example 1. R = ABCDEF, F = { AB C, BC AD, D E, CF B } Does AB D follow from F? Solve by checking D AB +. Computing AB+: 1. AB+ = AB (initially) 2. AB+ = ABC (using AB C) 3. AB+ = ABCD (using BC AD) 4. AB+ = ABCDE (using D E) Table 8 Since D is in AB+, then AB D does follow from F.

8 OpenStax-CNX module: m Keys Denition: A superkey of a relation schema R is set of attributes K R if given a relation r(r) and any two tuples t1 and t2 in r then t1[k] t2[k]. Denition: A key K of a relation schema R is a superkey and there is no proper subset of K that can be a key. Here, we have a similar denition of key of a relation schema given a set of functional dependencies. Given a relation schema R with a list of attributes U = [U+F07B] A1, A2,..., An [U+F07D], F is a set of functional dependencies, K is a set of attributes and K U. We can say K is a key of E if the followings hold. 1. K U F + 2. for all proper subset K' of K (K' K) then K U / F + The dierence between key and superkey is that a key has to be minimal. That means if K = { A1, A2,.., Ak} then K \ { Ai } is not a key for R for any Ai If a relation schema has more than one key, each is called a candidate key A candidate key will be chosen to be primary key. Algorithm for nding a candidate key of a relation schema Input: Relation schema R = { A1, A2,.., An}, set F of fds Output: A candidate key K for R. K = R for i = 1 to n do { Kt = K - {Ai} if Kt+ = R then K = Kt } Example: R = ABCDEF, F = { BC AD, D E, CF B }. Find a candidate key of this relation schema. 1. K = ABCDEF (initially) 2. K = BCDEF (BCDEF) + = R (using BC AD) so A is not in the key 3. K = CDEF (CDEF)+ = R (using CF B; BC AD) so B is not in the key 4. K = CDEF (DEF)+ = DEF R so DEF is not a key, C must be an attribute in key 5. K = CEF (CEF)+ = R (using CF B; BC AD) so D is not in the key 6. K = CF (CF)+ = R (using CF B; BC AD,D E) so E is not in the key 7. K = CF (C)+ = C R so F must be in the key Table 9 One candidate key for the given relation schema is CF 3.4 Minimal Covers For a given application, we can dene many dierent sets of fds with the same closure (e.g. F and G where F+ = G+) Minimal cover Fc for a set F of fds: Fc is equivalent to F all fds have the form X A (where A is a single attribute) it is not possible to make Fc smaller

9 OpenStax-CNX module: m either by deleting an fd or by deleting an attribute from an fd An fd d is redundant if (F-{d})+ = F+ An attribute A is redundant if (F {d} {d'}) + = F + (where d' is the same as d but with attribute A removed) Algorithm for computing minimal cover: Inputs: set F of fds Output: minimal cover Fc of F Fc = F Step 1: put fds into canonical form for each f in Fc like X -> {A1,..,An} Fc = Fc - {f} for each a in {A1,..,An} Fc = Fc union {X -> a} end end Step 2: eliminate redundant attributes for each f in Fc like X A for each b in X f' = (X-{b}) -> A; G = Fc - {f} Union {f'} if (G+ == Fc+) Fc = G end end Step 3: eliminate redundant functional dependencies for each f in Fc G = Fc - {f} if (G+ == Fc+) Fc = G end Example : R = ABC, F = { A BC, B C, A B, AB C } Compute the minimal cover: canonical fds: A B, A C, B C, AB C redundant attrs: A B, A C, B C, AB C redundant fds: A B, A C, B C This gives the minimal cover F C = {A B, B C}. Example: Let consider the relation schema R(ABCDEG) and a set of functional dependencies F = {AB C, C A, BC D, ACD B, D EG, BE C, CG BD, CE AG }. Find the minimal cover of F Canonical fds: F1 = {AB C, C A, BC D, ACD B, D E, D G, BE C, CG B, CG D, CE A, CE G } Find redundant attributes: Consider fd: ACD B, we have (CD)+ = ABCDEG it means CD B. A is a redundant attribute in that functional dependency. No other redundant attributes found. So we have

10 OpenStax-CNX module: m F2 = {AB C, C A, BC D, CD B, D E, D G, BE C, CG B, CG D, CE A, CE G } Find redundant functional dependency. Initially F0 = F2 Consider rst fd in F : AB C. With respect to the set F0 \ {AB C}, we have (AB)+ = AB. So the fd AB C cannot be inferred from others fds in the set F0 or F0 is not equivalent to F0 \ {AB C}. Therefore, we can have F1 = F0or the functional dependency AB C is not redundant. C A is not redundant or F2 = F1 because (C)+ = C with respect to the set F1 \ {C A} BC D is not redundant or F3 = F2 because (BC)+ = ABC with respect to the set F2 \ {BC D}. CD B is a redundant functional dependency because (CD)+ = ABCDEG with respect to the set F3 \ {CD B}. The closure of CD contains attribute B so that CD B can be inferred from remaining dependencies in the set. Therefore, F4 = F3 \ {CD B}. Similarly, the following functional dependencies are redundant: CG D, CE A Finally, the result of this step is F3 = {AB C, C A, BC D, D E, D G, BE C, CG B, CE G } This is the minimal cover of F. 4 Relation Decomposition As mention in the beginning of the lecture, in the bottom-up approach of designing relational database, we start from a single universal relation schema R = {A1, A2,...,An} that includes all the attributes of the database. Given a set of functional dependencies F that should hold on the attributes of R, we can use the dependencies to decompose the relation R into a set of relation schemas D = {R1, R2,..., Rk} with R 1 R 2... R K = R. This means each new relation scheme contains a subset of attributes of R and every attributes of R appears as an attribute in one of the new relations. D is called a relation decomposition of R. For a relation decomposition, there are two desirable properties: Dependency preservation property ensures that each functional dependency can be represented in some individual relation resulting after decomposition Lossless join property ensures No information is loss after decomposition. 4.1 Lossless Join Property of Decomposition Denition: A decomposition D = {R1, R2,..., Rk} of a relation schema R has lossless join property with respect to a set of functional dependencies F on R if for any relation r(r) that satises F, we have r = Π R1 (r) Π R2 (r)... Π Rk (r) Algorithm for testing for lossless join decomposition Input: Relation schema R = { A1, A2,.., An}, set F of fds, a decomposition D = {R1, R2,..., Rk} Output:Check whether D is lossless join decomposition or not Create a matrix T with k rows and n columns. Row i in the matrix corresponds to relation Ri in D. Column j in the matrix corresponds to attribute Aj in R. Set the values for an entry in the matrix T: T(i,j)= a(i,j) if relation Ri includes attribute Aj. Othewise, T(i,j)= b(i,j) Repeat the following loop until a complete loop execution results in no changes to T

11 OpenStax-CNX module: m for each funtional dependency X -> Y in F{ for all rows in T that have the same values in the columns corresponds to attributes in X { Make the symbols in each column that correspond to an attribute in Y be the same in all these rows : if any of the row has an `a' symbol for the column, set other rows to that same `a' symbol in the column. otherwise, choose one of the `b' symbol to set to other rows in the column. } } If a row is made up entirely of `a' symbol then the decomposition is lossless join. Otherwise, the decomposition is lossy join. Example: Let relation schema R = ABCDE,; decomposition D is {R1 = AD, R2 = AB, R3 = BE, R4 = CDE và R5 = AE} ; a set of funtional dependencies F = {A C, B C, C D, DE C, CE A }. D is lossless join decomposition or not? According to algorithm, the initial matrix T is: A B C D E row 1 a1 b12 b13 a4 b15 row 2 a1 a2 b23 b24 b25 row 3 b31 a2 b33 b34 a5 row 4 b41 b42 a3 a4 a5 row 5 a1 b52 b53 b54 a5 Table 10 Using the functional dependency A C we have, rows 1, 2, 5 have the same symbol in column A, so make the symbol in column C to be the same as b13. A B C D E a1 b12 b13 a4 b15 a1 a2 b13 b24 b25 b31 a2 b33 b34 a5 b41 b42 a3 a4 a5 a1 b52 b13 b54 a5 Table 11 Using the functional dependency B C, rows 2,3 have the same symbol in column B so make the symbol in column C to be the same as b13

12 OpenStax-CNX module: m A B C D E a1 b12 b13 a4 b15 a1 a2 b13 b24 b25 b31 a2 b13 b34 a5 b41 b42 a3 a4 a5 a1 b52 b13 b54 a5 Table 12 Using the functional dependency C D, row 1, 2, 3, 5 have the same symbol in column C so make the values of column D to be the the same: b24, b34, b54 become a4 A B C D E a1 b12 b13 a4 b15 a1 a2 b13 a4 b25 b31 a2 b13 a4 a5 b41 b42 a3 a4 a5 a1 b52 b13 a4 a5 Table 13 Using DE C, rows 3, 4, 5 have the same symbols in columns D,E so make the symbol of column C to be the same: b13 becomes a3. A B C D E a1 b12 b13 a4 b15 a1 a2 b13 a4 b25 b31 a2 a3 a4 a5 b41 b42 a3 a4 a5 a1 b52 a3 a4 a5 Table 14 Using CE A, row 3, 4, 5 have the same symbols in columns C, E so make the symbol in column A be the same: b31, b41 become a1 A B C D E a1 b12 b13 a4 b15 a1 a2 b13 a4 b25 a1 a2 a3 a4 a5 a1 b42 a3 a4 a5 a1 b52 a3 a4 a5

13 OpenStax-CNX module: m Table 15 There is a row 3 contains all `a' symbol so this decomposition is lossless. 5 Dependency Preservation of Decomposition In addition of lossless join, dependency preservation is a desirable property of decomposition. The functional dependency is a constraint in the database, we don't want any constraint disappear because of the decomposition. Given a relation schema R, set of functional dependencies F on R and a decomposition D It is not necessary that the exact dependencies specied on set F appear directly in one of the relation of D. However, the set of all the dependencies that hold on relations in D must be equivalent to F. Denition: Given a relation schema R and a set of functional dependencies F of R ; D= (R1, R2,., Rk) is a decomposition of R on F. We say Fi is a projection of F on Ri, denoted by Π Ri (F ), is the set of dependencies X Y F + such that XY R i. We say that a decomposition D = {R1, R2,..., Rk} is dependency-preserving with respect to F if (Π R1 (F ) Π R2 (F )... Π R3 (F ) ) + = F + Example: Let consider the relation R (CITY, STREET, ZIP) Simply, we can use the name C for CITY, S for STREET, Z for ZIP. The set of funtional dependencies in R consists of CS Z and Z C. Suppose we have a decomposition D = {R1 = SZ and R2 = CZ }. The projection of F on R1 contains only trivial dependencies that can be inferred using reexivity rule. The projection of F on R2 consists of trivial dependencies and Z C. We can see that the set F' of Z C and trivial dependencies cannot derive the dependency CS Z. Thus, this decomposition of R does not preserve dependency 6 Normalization Normalization is the branch of relational theory providing design insights. The goals of normalization are: be able to characterise the level of redundancy in a relational schema provide mechanisms for transforming schemas to remove redundancy Normalization draws heavily on the theory of functional dependencies. Normalization theory denes six normal forms (NFs). Each normal form involves a set of dependency properties that a schema must satisfy and each gives guarantees about presence/absence of update anomalies. That means higher normal forms have less redundancy so that less update problems. 6.1 Normal Forms A brief history of normal forms: First,Second,Third Normal Forms (1NF,2NF,3NF) (Codd 1972) Boyce-Codd Normal Form (BCNF) (1974) Fourth Normal Form (4NF) (Zaniolo 1976, Fagin 1977) Fifth Normal Form (5NF) (Fagin 1979) NF hierarachy: 5NF 4NF BCNF 3NF 2NF 1NF 1NF allows most redundancy; 5NF allows least redundancy.

14 OpenStax-CNX module: m NF 2NF 3NF, BCNF 4NF 5NF all attributes have atomic values we assume this as part of relational model all non-key attributes fully depend on key (i.e. no partial dependencies) avoids much redundancy no attributes dependent on nonkey attrs(i.e. no transitive dependencies) avoids remaining redundancy Removes problems due to multivalued dependencies Removes problems due to join dependencies Table 16 In practice, BCNF and 3NF are the most important. Boyce-Codd Normal Form (BCNF): eliminates all redundancy due to functional dependencies but may not preserve original functional dependencies Third Normal Form (3NF): eliminates most (but not all) redundancy due to fds guaranteed to preserve all functional dependencies In the following sections, we will give a more detail denition of the normal forms. Before move into details of the normal forms, we state some related denition. Denition: Let R be a relation schema with the set of attributes U = {A1, A2,..., An }, F is the set of functional dependencies hold on R ; A is an attributes in U. A is called prime attribute if A appears in some candidate keys of R. If A is not a member of any candidate key of R then A is nonprime attribute. Example : Given R (A,B,C,D) with a set of functional dependencies F = {AB C, BC A, B D}. There are two candidate keys of R which are AB and BC. Therefore, the prime attributes of R are A, B and C. D is a nonprime attribute. Denition: Consider a relation schema R with set of attributes U= { A1, A2,..., An }, F is a set of functional dependencies on R and X, Y U. We say that Y is fully functionally dependent on X if: X Y F + With all proper subset X' of X, X ' Y / F + Otherwise, we say that Y is partially functionally dependent on X. Denition: Consider a relation schema R with set of attributes U = { A1, A2,..., An }, F is a set of functional dependencies on R and X, Y U. A functional dependency X Y is a transitive dependency if there is a set of attributes Z that is neither a candidate key nor a subset of any key of R and X Z, Z Y hold.

15 OpenStax-CNX module: m First Normal Form (1NF) Denition: A relation schema R is in First Normal Form if the domains of all attributes of R are atomic. A relation is in 1NF if the corresponding is in 1NF. A domain is atomic if elements of the domain are considered to be indivisible units. First Normal Form is dened to disallow multivalued attributes, composite attributes and their combination. In a relation instance of a 1NF relation schema, there is no set of values, tuple of values or a combination of both as an attribute value for a single tuple. Example of relation instance of relation schema which is not in 1NF Table 17 The 1NF version of the same relation with redundancy EMP - PROJ EMP-PROJ EID Name Address Birthdate Project PName StartDate 1 John Smith 12/34 Meeks 26/7/1976 GreenLife 1/1/2006 Str, Green- Garden ProductX 15/7/ Mary Streep 123 King 12/2/1978 ProductX 1/2/2007 Str, Marryland Networld 15/8/1007 EID Name Address Birthdate PName StartDate 1 John Smith 12/34 Meeks 26/7/1976 GreenLife 1/1/2006 Str, Green- Garden 1 John Smith 12/34 Meeks 26/7/1976 ProductX 15/7/1007 Str, Green- Garden 2 Mary Streep 123 King 12/2/1978 ProductX 1/2/2007 Str, Marryland continued on next page

16 OpenStax-CNX module: m Mary Streep 123 King Str, Marryland 12/2/1978 Networld 15/8/1007 Table Second Normal Form (2NF) This normal form is based on concept of full functional dependency (mentioned above). Denition: A relation schema R is in 2NF if it is in 1NF and every nonprime attribute A in R is fully funtionally dependent on the primary key of R. Example: Consider a relation schema EMP-PROJ above. The set of functional dependencies in this relation schema consist of two fds: EID Name, Address, Birthdate and EID, PName StartDate. The only candidate key for this relation schema is {EID, PName}. The nonprime attributes are Name, Address, Birthdate, StartDate. Nonprime attributes Name, Address, Birthdate violate 2NF because they are funtionally dependent only on EID which is a part of the key. If a relation schema is not in 2NF, we can normalized into several 2NF relations in which nonprime attributes are associated only with the part of key on which they are fully functionally dependent. Therefore, we normalized the EMP-PROJ into two 2NF relations as follows EMPLOYEE EID Name Address Birthdate 1 John Smith 12/34 Meeks Str, GreenGarden 26/7/ Mary Streep 123 King Str, Marryland 12/2/1978 Table 19 EMP-PROJ EID PName StartDate 1 GreenLife 1/1/ ProductX 15/7/ ProductX 1/2/ Networld 15/8/1007 Table Third Normal Form (3NF) This normal form is based on concept of transivtive functional dependency. Denition: A relation schema R is in 3NF if it is in 2NF and no nonprime attribute in R is transitively dependent on the primary key of R. Example: Consider the relation schema EMP-DEPT (EID, Name, Address, Birthdate, DeptId, Dept- Name, Dept-Manager). In this relation schema, suppose that the followings funtional dependencies hold {EID Name, Address, Birthdate, DeptId, DeptId DeptName, Dept-Manager} The primary of this relation schema is {EID}. This relation schema is in 2NF. However, the nonprime attributes DeptName, Dept-Manager is transitively dependent on primary key (since we got EID DeptId and DeptId DeptName, Dept-Manager) so it is not in 3NF. Algorithm : Decompose relation schema into 3NF schemas with Dependency Preserving Input: Relation schema R, set of functional dependencies F Output: A decomposition D - consists of relations which are all in 3NF with dependency preserving

17 OpenStax-CNX module: m Find a minimal cover G of F 2. If there are attributes in R that do not appear in any functional dependency in F, then place them into a relation schema and remove them from R. 3. For each functional dependency X A in F, create a relation schema in D with attributes {X A}. If there are several funtional dependencies in F with the same left-hand-side X (such as X A1,..., X Ak) then create a relation shema which includes all attributes { X A1 A2.. Ak }. Example: Let consider the relation schema R(ABCDEG) and a set of functional dependencies F = {AB C, C A, BC D, ACD B, D EG, BE C, CG BD, CE AG }. Find the decomposition in 3NF with dependency preserving. 1. The minimal cover of F is Fc = {AB C, C A, BC D, D E, D G, BE C, CG B, CE G} (from the example in the section of Minimal Cover) 2. All attributes in R are members of at least one functional dependency in F, so we can use the functional dependency to decompose relation schema R. The result is D = (ABC, CA, BCD, DEG, BEC, CGB, CEG). However, because CA [U+F0CC] ABC so we can remove relation schema CA from D and the nal result is D = (ABC, BCD, DEG, BEC, CGB, CEG) Algorithm: Decompose relation schema into 3NF schemas with Dependency Preserving and Lossless Join Input: Relation schema R, set of funtional dependencies F Output: A decomposition D - consists of relations which are all in 3NF with dependency preserving 1. Find a minimal cover Fc of F 2. Find a key of relation schema R with respect to G (algorithm in section Keys). Result is K 3. Find a decomposition into 3NF schemas with Dependency Preserving. Result is D (Previous algorithm) 4. If none of the relation schemas in D contains key K of R then create one more relation schema in D that contains attributes that form K. Otherwise, D is the result of this algorithm. Example: Let consider the relation schema R(ABCDEG) and a set of functional dependencies F = {AB C, C A, BC D, ACD B, D EG, BE C, CG BD, CE AG }. Find the decomposition in 3NF with dependency preserving and lossless join. 1. Minimal cover of F: Fc = {AB C, C A, BC D, D E, D G, BE C, CG B, CE G} 2. Find a key K follows the algorithm in section Keys K0 = ABCDEG K1 = K0 \ A = BCDEG because BCDEG ABCDEG F + K2 = K1 \ B = CDEG because CDEG ABCDEG F + K3 = K2 = CDEG because DEG ABCDEG / F + K4 = K3 \ D = CEG because CEG ABCDEG F + K5 = K4 \ E = CG because CG ABCDEG F + K6 = K5 = CG because C ABCDEG / F + The resulting key is CG. 1. Using the result of previous example, we have a decomposition D with dependency preserving is D = (ABC, BCD, DEG, BEC, CGB, CEG) 2. The relation schema CGB in D contains the key CG, so D is a dependency preserving and lossless join decomposition of R into 3NF relation schemas.

18 OpenStax-CNX module: m Boyce-Codd Normal Form Denition: A relation schema R is in BCNF with respect to a set F of functional dependencies if for all fds X Y in F+ either X Y is trivial (i.e. Y X) or X is a superkey A relation is in BCNF is its schema is in BCNF A database schema is in BCNF if all relation schemas are in BCNF. Example: Given the relation schema R(A B C D E F) ; Set of functional dependencies F = {A BC, E AF}. The key of R is DE. This relation schema is not in BCNF because the functional dependencies violate the conditions of BCNF ( all functional dependencies in F are not trivial and all left hand side attributes are not superkey) If we transform a schema into BCNF, we are guaranteed: no update anomalies due to fd-based redundancy lossless join decomposition However, we are not guaranteed: all fds from the original schema exist in the new schema This may be a problem if the fds contain signicant semantic information about the problem domain. If we need to preserve dependencies, use 3NF. Algorithm converts an arbitrary schema to BCNF Inputs: schema R, set F of fds Output: set D of BCNF schemas D = {R}; while (any schema (S belong to D) is not in BCNF) { choose an fd X Y on S that violates BCNF D = (D S) (S Y ) XY } Example: With the previous example R(A B C D E F) ; Set of functional dependencies F = {A BC, E AF}. R is not in BCNF, both functional dependencies violate the conditions of BCNF. Using A BC to decompose we have D1 = {ABC, ADEF}. The relation schema R1(ABC) is in BCNF with respect to projection F1 = { A BC}. However, relation schema R2(ADEF) is not in BCNF with respect to projection F2 = { E AF} because the key of R2 is DE and the left-hand-side of the functional dependency is not a superkey. Therefore, we have to decompose R2 R2 is decomposed into R21(AEF) and R22(DE) using E AF The nal result is D = {ABC, AEF, DE}

UNIT 3 DATABASE DESIGN

UNIT 3 DATABASE DESIGN UNIT 3 DATABASE DESIGN Objective To study design guidelines for relational databases. To know about Functional dependencies. To have an understanding on First, Second, Third Normal forms To study about

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization CSE 544 Principles of Database Management Systems Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to this

More information

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization CSE 544 Principles of Database Management Systems Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization References R&G Book. Chapter 19: Schema refinement and normal forms Also relevant to

More information

COSC Dr. Ramon Lawrence. Emp Relation

COSC Dr. Ramon Lawrence. Emp Relation COSC 304 Introduction to Database Systems Normalization Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Normalization Normalization is a technique for producing relations

More information

CS411 Database Systems. 05: Relational Schema Design Ch , except and

CS411 Database Systems. 05: Relational Schema Design Ch , except and CS411 Database Systems 05: Relational Schema Design Ch. 3.1-3.5, except 3.4.2-3.4.3 and 3.5.3. 1 How does this fit in? ER Diagrams: Data Definition Translation to Relational Schema: Data Definition Relational

More information

Chapter 8: Relational Database Design

Chapter 8: Relational Database Design Chapter 8: Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 8: Relational Database Design Features of Good Relational Design Atomic Domains

More information

UNIT -III. Two Marks. The main goal of normalization is to reduce redundant data. Normalization is based on functional dependencies.

UNIT -III. Two Marks. The main goal of normalization is to reduce redundant data. Normalization is based on functional dependencies. UNIT -III Relational Database Design: Features of Good Relational Designs- Atomic Domains and First Normal Form- Second Normal Form-Decomposition Using Functional Dependencies- Functional-Dependency Theory-Algorithms

More information

MODULE: 3 FUNCTIONAL DEPENDENCIES

MODULE: 3 FUNCTIONAL DEPENDENCIES MODULE: 3 (13 hours) Database design: functional dependencies - Inference Rules for Functional Dependencies - Closure -- Minimal Cover -Normal forms First-second and third normal forms Boyce- Codd normal

More information

Informal Design Guidelines for Relational Databases

Informal Design Guidelines for Relational Databases Outline Informal Design Guidelines for Relational Databases Semantics of the Relation Attributes Redundant Information in Tuples and Update Anomalies Null Values in Tuples Spurious Tuples Functional Dependencies

More information

Fundamentals of Database Systems

Fundamentals of Database Systems Fundamentals of Database Systems Assignment: 3 Due Date: 23st August, 2017 Instructions This question paper contains 15 questions in 6 pages. Q1: Consider the following relation and its functional dependencies,

More information

Unit 3 : Relational Database Design

Unit 3 : Relational Database Design Unit 3 : Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Content Relational Model: Basic concepts, Attributes and Domains, CODD's Rules, Relational

More information

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24

Databases -Normalization I. (GF Royle, N Spadaccini ) Databases - Normalization I 1 / 24 Databases -Normalization I (GF Royle, N Spadaccini 2006-2010) Databases - Normalization I 1 / 24 This lecture This lecture introduces normal forms, decomposition and normalization. We will explore problems

More information

BCNF. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong BCNF

BCNF. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong BCNF Yufei Tao Department of Computer Science and Engineering Chinese University of Hong Kong Recall A primary goal of database design is to decide what tables to create. Usually, there are two principles:

More information

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT

Functional Dependencies & Normalization for Relational DBs. Truong Tuan Anh CSE-HCMUT Functional Dependencies & Normalization for Relational DBs Truong Tuan Anh CSE-HCMUT 1 2 Contents 1 Introduction 2 Functional dependencies (FDs) 3 Normalization 4 Relational database schema design algorithms

More information

Relational Design: Characteristics of Well-designed DB

Relational Design: Characteristics of Well-designed DB 1. Minimal duplication Relational Design: Characteristics of Well-designed DB Consider table newfaculty (Result of F aculty T each Course) Id Lname Off Bldg Phone Salary Numb Dept Lvl MaxSz 20000 Cotts

More information

Steps in normalisation. Steps in normalisation 7/15/2014

Steps in normalisation. Steps in normalisation 7/15/2014 Introduction to normalisation Normalisation Normalisation = a formal process for deciding which attributes should be grouped together in a relation Normalisation is the process of decomposing relations

More information

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.)

Chapter 10. Normalization. Chapter Outline. Chapter Outline(contd.) Chapter 10 Normalization Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant Information in Tuples and Update Anomalies 1.3 Null

More information

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2 Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2 Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant

More information

The Relational Data Model

The Relational Data Model The Relational Data Model Lecture 6 1 Outline Relational Data Model Functional Dependencies Logical Schema Design Reading Chapter 8 2 1 The Relational Data Model Data Modeling Relational Schema Physical

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms M. Tamer Özsu David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Fall 2012 CS 348 Schema Refinement

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms Grant Weddell Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2016 CS 348 (Intro to DB Mgmt)

More information

Database Design Theory and Normalization. CS 377: Database Systems

Database Design Theory and Normalization. CS 377: Database Systems Database Design Theory and Normalization CS 377: Database Systems Recap: What Has Been Covered Lectures 1-2: Database Overview & Concepts Lecture 4: Representational Model (Relational Model) & Mapping

More information

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design 1 Normalization What and Why Normalization? To remove potential redundancy in design Redundancy causes several anomalies: insert, delete and update Normalization uses concept of dependencies Functional

More information

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems

Functional Dependencies and Normalization for Relational Databases Design & Analysis of Database Systems Functional Dependencies and Normalization for Relational Databases 406.426 Design & Analysis of Database Systems Jonghun Park jonghun@snu.ac.kr Dept. of Industrial Engineering Seoul National University

More information

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant

More information

customer = (customer_id, _ customer_name, customer_street,

customer = (customer_id, _ customer_name, customer_street, Relational Database Design COMPILED BY: RITURAJ JAIN The Banking Schema branch = (branch_name, branch_city, assets) customer = (customer_id, _ customer_name, customer_street, customer_city) account = (account_number,

More information

Functional Dependencies and Normalization

Functional Dependencies and Normalization Functional Dependencies and Normalization Jose M. Peña jose.m.pena@liu.se Overview Real world Databases DBMS Model Physical database Queries Processing of queries and updates Access to stored data Answers

More information

Chapter 7: Relational Database Design

Chapter 7: Relational Database Design Chapter 7: Relational Database Design Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 7: Relational Database Design Features of Good Relational Design Atomic Domains

More information

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization.

This lecture. Databases -Normalization I. Repeating Data. Redundancy. This lecture introduces normal forms, decomposition and normalization. This lecture Databases -Normalization I This lecture introduces normal forms, decomposition and normalization (GF Royle 2006-8, N Spadaccini 2008) Databases - Normalization I 1 / 23 (GF Royle 2006-8, N

More information

Lecture 11 - Chapter 8 Relational Database Design Part 1

Lecture 11 - Chapter 8 Relational Database Design Part 1 CMSC 461, Database Management Systems Spring 2018 Lecture 11 - Chapter 8 Relational Database Design Part 1 These slides are based on Database System Concepts 6th edition book and are a modified version

More information

Functional Dependencies CS 1270

Functional Dependencies CS 1270 Functional Dependencies CS 1270 Constraints We use constraints to enforce semantic requirements on a DBMS Predicates that the DBMS must ensure to be always true. Predicates are checked when the DBMS chooses

More information

Database Management System

Database Management System Database Management System Lecture 4 Database Design Normalization and View * Some materials adapted from R. Ramakrishnan, J. Gehrke and Shawn Bowers Today s Agenda Normalization View Database Management

More information

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys)

Functional Dependencies and. Databases. 1 Informal Design Guidelines for Relational Databases. 4 General Normal Form Definitions (For Multiple Keys) 1 / 13 1 Informal Design Guidelines for Relational Databases 1.1Semantics of the Relation Attributes 1.2 Redundant d Information in Tuples and Update Anomalies 1.3 Null Values in Tuples 1.4 Spurious Tuples

More information

Relational Database Design Theory. Introduction to Databases CompSci 316 Fall 2017

Relational Database Design Theory. Introduction to Databases CompSci 316 Fall 2017 Relational Database Design Theory Introduction to Databases CompSci 316 Fall 2017 2 Announcements (Thu. Sep. 14) Homework #1 due next Tuesday (11:59pm) Course project description posted Read it! Mixer

More information

Functional Dependencies and Finding a Minimal Cover

Functional Dependencies and Finding a Minimal Cover Functional Dependencies and Finding a Minimal Cover Robert Soulé 1 Normalization An anomaly occurs in a database when you can update, insert, or delete data, and get undesired side-effects. These side

More information

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies

Chapter 14. Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies Chapter 14 Database Design Theory: Introduction to Normalization Using Functional and Multivalued Dependencies Copyright 2012 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines

More information

CSE 562 Database Systems

CSE 562 Database Systems Goal CSE 562 Database Systems Question: The relational model is great, but how do I go about designing my database schema? Database Design Some slides are based or modified from originals by Magdalena

More information

Database Design Principles

Database Design Principles Database Design Principles CPS352: Database Systems Simon Miner Gordon College Last Revised: 2/11/15 Agenda Check-in Design Project ERD Presentations Database Design Principles Decomposition Functional

More information

Relational Database Design (II)

Relational Database Design (II) Relational Database Design (II) 1 Roadmap of This Lecture Algorithms for Functional Dependencies (cont d) Decomposition Using Multi-valued Dependencies More Normal Form Database-Design Process Modeling

More information

Schema Refinement: Dependencies and Normal Forms

Schema Refinement: Dependencies and Normal Forms Schema Refinement: Dependencies and Normal Forms Grant Weddell David R. Cheriton School of Computer Science University of Waterloo CS 348 Introduction to Database Management Spring 2012 CS 348 (Intro to

More information

Typical relationship between entities is ((a,b),(c,d) ) is best represented by one table RS (a,b,c,d)

Typical relationship between entities is ((a,b),(c,d) ) is best represented by one table RS (a,b,c,d) Mapping ER Diagrams to a relational database.. Binary relationships: Three possible configurations: 1. One table.. 2. Two tables.. 3. Three tables.. 1-1 relationships R(AB) - S(CD) Typical relationship

More information

Review: Attribute closure

Review: Attribute closure CS445 - Introduction to Database Management Systems Fall Semester 2015 LECTURE 10 Functional Dependencies, Normalization Part II TEXTBOOK REFERENCE: CHAPTER 19 CS445 DATABASES: LECTURE 10 1 Review: Attribute

More information

5 Normalization:Quality of relational designs

5 Normalization:Quality of relational designs 5 Normalization:Quality of relational designs 5.1 Functional Dependencies 5.1.1 Design quality 5.1.2 Update anomalies 5.1.3 Functional Dependencies: definition 5.1.4 Properties of Functional Dependencies

More information

Schema Refinement and Normal Forms

Schema Refinement and Normal Forms Schema Refinement and Normal Forms Chapter 19 Quiz #2 Next Wednesday Comp 521 Files and Databases Fall 2010 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational

More information

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product In This Lecture Normalisation to BCNF Database Systems Lecture 12 Natasha Alechina More normalisation Brief review of relational algebra Lossless decomposition Boyce-Codd normal form (BCNF) Higher normal

More information

LOGICAL DATABASE DESIGN Part #2/2

LOGICAL DATABASE DESIGN Part #2/2 NOTE, the decomposition algorithms (2NF in p. 10-11, 3NF in p. 14-16, and BCNF in P. 18) have been modified. Read the algorithms very carefully. LOGICAL DATABASE DESIGN Part #2/2 Relational Database Design

More information

Design Theory for Relational Databases

Design Theory for Relational Databases By Marina Barsky Design Theory for Relational Databases Lecture 15 Functional dependencies: formal definition X Y is an assertion about a relation R that whenever two tuples of R agree on all the attributes

More information

Database Systems. Basics of the Relational Data Model

Database Systems. Basics of the Relational Data Model Database Systems Relational Design Theory Jens Otten University of Oslo Jens Otten (UiO) Database Systems Relational Design Theory INF3100 Spring 18 1 / 30 Basics of the Relational Data Model title year

More information

CS 2451 Database Systems: Database and Schema Design

CS 2451 Database Systems: Database and Schema Design CS 2451 Database Systems: Database and Schema Design http://www.seas.gwu.edu/~bhagiweb/cs2541 Spring 2018 Instructor: Dr. Bhagi Narahari Relational Model: Definitions Review Relations/tables, Attributes/Columns,

More information

CSIT5300: Advanced Database Systems

CSIT5300: Advanced Database Systems CSIT5300: Advanced Database Systems L06: Relational Database Design BCNF Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR,

More information

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 19 Relational Database Design (Contd.) Welcome to module

More information

The strategy for achieving a good design is to decompose a badly designed relation appropriately.

The strategy for achieving a good design is to decompose a badly designed relation appropriately. The strategy for achieving a good design is to decompose a badly designed relation appropriately. Functional Dependencies The single most important concept in relational schema design theory is that of

More information

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18 NORMAL FORMS CS121: Relational Databases Fall 2017 Lecture 18 Equivalent Schemas 2 Many different schemas can represent a set of data Which one is best? What does best even mean? Main goals: Representation

More information

Database Management Systems Paper Solution

Database Management Systems Paper Solution Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of

More information

Relational Design Theory. Relational Design Theory. Example. Example. A badly designed schema can result in several anomalies.

Relational Design Theory. Relational Design Theory. Example. Example. A badly designed schema can result in several anomalies. Relational Design Theory Relational Design Theory A badly designed schema can result in several anomalies Update-Anomalies: If we modify a single fact, we have to change several tuples Insert-Anomalies:

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 14 Basics of Functional Dependencies and Normalization for Relational Databases Slide 14-2 Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1 Semantics of the Relation Attributes

More information

Relational Database design. Slides By: Shree Jaswal

Relational Database design. Slides By: Shree Jaswal Relational Database design Slides By: Shree Jaswal Topics: Design guidelines for relational schema, Functional Dependencies, Definition of Normal Forms- 1NF, 2NF, 3NF, BCNF, Converting Relational Schema

More information

Databases The theory of relational database design Lectures for m

Databases The theory of relational database design Lectures for m Databases The theory of relational database design Lectures for mathematics students April 2, 2017 General introduction Look; that s why there s rules, understand? So that you think before you break em.

More information

QUESTION BANK. SUBJECT CODE / Name: CS2255 DATABASE MANAGEMENT SYSTEM UNIT III. PART -A (2 Marks)

QUESTION BANK. SUBJECT CODE / Name: CS2255 DATABASE MANAGEMENT SYSTEM UNIT III. PART -A (2 Marks) QUESTION BANK DEPARTMENT: CSE SEMESTER: IV SUBJECT CODE / Name: CS2255 DATABASE MANAGEMENT SYSTEM UNIT III PART -A (2 Marks) 1. Explain the two conditions needed for the set difference operation (union

More information

Functional dependency theory

Functional dependency theory Functional dependency theory Introduction to Database Design 2012, Lecture 8 Course evaluation Recalling normal forms Functional dependency theory Computing closures of attribute sets BCNF decomposition

More information

Unit IV. S_id S_Name S_Address Subject_opted

Unit IV. S_id S_Name S_Address Subject_opted Page no: 1 Unit IV Normalization of Database Database Normalizations is a technique of organizing the data in the database. Normalization is a systematic approach of decomposing tables to eliminate data

More information

Normalization is based on the concept of functional dependency. A functional dependency is a type of relationship between attributes.

Normalization is based on the concept of functional dependency. A functional dependency is a type of relationship between attributes. Lecture Handout Database Management System Lecture No. 19 Reading Material Database Systems Principles, Design and Implementation written by Catherine Ricardo, Maxwell Macmillan. Section 7.1 7.7 Database

More information

SCHEMA REFINEMENT AND NORMAL FORMS

SCHEMA REFINEMENT AND NORMAL FORMS 19 SCHEMA REFINEMENT AND NORMAL FORMS Exercise 19.1 Briefly answer the following questions: 1. Define the term functional dependency. 2. Why are some functional dependencies called trivial? 3. Give a set

More information

V. Database Design CS448/ How to obtain a good relational database schema

V. Database Design CS448/ How to obtain a good relational database schema V. How to obtain a good relational database schema Deriving new relational schema from ER-diagrams Normal forms: use of constraints in evaluating existing relational schema CS448/648 1 Translating an E-R

More information

COMP7640 Assignment 2

COMP7640 Assignment 2 COMP7640 Assignment 2 Due Date: 23:59, 14 November 2014 (Fri) Description Question 1 (20 marks) Consider the following relational schema. An employee can work in more than one department; the pct time

More information

Lecture 6a Design Theory and Normalization 2/2

Lecture 6a Design Theory and Normalization 2/2 CompSci 516 Data Intensive Computing Systems Lecture 6a Design Theory and Normalization 2/2 Instructor: Sudeepa Roy 1 HW1 deadline: Announcements Due on 09/21 (Thurs), 11:55 pm, no late days Project proposal

More information

Chapter 14 Outline. Normalization for Relational Databases: Outline. Chapter 14: Basics of Functional Dependencies and

Chapter 14 Outline. Normalization for Relational Databases: Outline. Chapter 14: Basics of Functional Dependencies and Ramez Elmasri, Shamkant B. Navathe(2016) Fundamentals of Database Systems (7th Edition), pearson, isbn 10: 0-13-397077-9;isbn-13:978-0-13-397077-7. Chapter 14: Basics of Functional Dependencies and Normalization

More information

TDDD12 Databasteknik Föreläsning 4: Normalisering

TDDD12 Databasteknik Föreläsning 4: Normalisering What is Good Design TDDD12 Databasteknik Föreläsning 4: Normalisering Can we be sure that the translation from the EER diagram to relational tables results in a good database design? Or: Confronted with

More information

Normalisation. Normalisation. Normalisation

Normalisation. Normalisation. Normalisation Normalisation Normalisation Main objective in developing a logical data model for relational database systems is to create an accurate and efficient representation of the data, its relationships, and constraints

More information

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise CSC 74 Database Management Systems Topic #6: Database Design Weak Entity Type E Create a relation R Include all simple attributes and simple components of composite attributes. Include the primary key

More information

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms Normalization Niklas Fors (niklas.fors@cs.lth.se) Normalization 1 / 45

More information

Dr. Anis Koubaa. Advanced Databases SE487. Prince Sultan University

Dr. Anis Koubaa. Advanced Databases SE487. Prince Sultan University Advanced Databases Prince Sultan University College of Computer and Information Sciences Fall 2013 Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases Anis Koubaa SE487

More information

Normal Forms. Winter Lecture 19

Normal Forms. Winter Lecture 19 Normal Forms Winter 2006-2007 Lecture 19 Equivalent Schemas Many schemas can represent a set of data Which one is best? What does best even mean? Main goals: Representation must be complete Data should

More information

We shall represent a relation as a table with columns and rows. Each column of the table has a name, or attribute. Each row is called a tuple.

We shall represent a relation as a table with columns and rows. Each column of the table has a name, or attribute. Each row is called a tuple. Logical Database design Earlier we saw how to convert an unorganized text description of information requirements into a conceptual design, by the use of ER diagrams. The advantage of ER diagrams is that

More information

Chapter 6: Relational Database Design

Chapter 6: Relational Database Design Chapter 6: Relational Database Design Chapter 6: Relational Database Design Features of Good Relational Design Atomic Domains and First Normal Form Decomposition Using Functional Dependencies Second Normal

More information

FUNCTIONAL DEPENDENCIES

FUNCTIONAL DEPENDENCIES FUNCTIONAL DEPENDENCIES CS 564- Spring 2018 ACKs: Dan Suciu, Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? Database Design Theory: Functional Dependencies Armstrong s rules The Closure Algorithm

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Logical Design Lecture 03 zain 1 Database Design Process Application 1 Conceptual requirements Application 1 External Model Application 2 Application 3 Application 4 External

More information

Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please)

Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please) Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2016, Prakash Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please) Reminders: a. Out of 100 points.

More information

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<<

Draw A Relational Schema And Diagram The Functional Dependencies In The Relation >>>CLICK HERE<<< Draw A Relational Schema And Diagram The Functional Dependencies In The Relation I need to draw relational schema and dependency diagram showing transitive and partial Functional dependency and normalization

More information

CSCI 403: Databases 13 - Functional Dependencies and Normalization

CSCI 403: Databases 13 - Functional Dependencies and Normalization CSCI 403: Databases 13 - Functional Dependencies and Normalization Introduction The point of this lecture material is to discuss some objective measures of the goodness of a database schema. The method

More information

Redundancy:Dependencies between attributes within a relation cause redundancy.

Redundancy:Dependencies between attributes within a relation cause redundancy. Normalization Normalization: It is the process of removing redundant data from your tables in order to improve storage efficiency, data integrity and scalability. This improvement is balanced against an

More information

Functional Dependencies and Single Valued Normalization (Up to BCNF)

Functional Dependencies and Single Valued Normalization (Up to BCNF) Functional Dependencies and Single Valued Normalization (Up to BCNF) Harsh Srivastava 1, Jyotiraditya Tripathi 2, Dr. Preeti Tripathi 3 1 & 2 M.Tech. Student, Centre for Computer Sci. & Tech. Central University

More information

Normalization 03. CSE3421 notes

Normalization 03. CSE3421 notes Normalization 03 CSE3421 notes 1 Example F: A B (1) ABCD E (2) EF G (3) EF H (4) ACDF EG (5) Calculate the minimal cover of F. 2 Step 1: Put F in standard form FDs (1) (4) are already in standard form.

More information

Part V Relational Database Design Theory

Part V Relational Database Design Theory Part V Relational Database Design Theory Relational Database Design Theory 1 Target Model of the Logical Design 2 Relational DB Design 3 Normal Forms 4 Transformation Properties 5 Design Methods Saake

More information

Course Content. Database Design Theory. Objectives of Lecture 2 Database Design Theory. CMPUT 391: Database Design Theory

Course Content. Database Design Theory. Objectives of Lecture 2 Database Design Theory. CMPUT 391: Database Design Theory Database Management Systems Winter 2003 CMPUT 391: Database Design Theory Dr. Osmar R. Zaïane University of Alberta Chapter 19 of Textbook Course Content Introduction Database Design Theory Query Processing

More information

CS352 Lecture - Conceptual Relational Database Design

CS352 Lecture - Conceptual Relational Database Design CS352 Lecture - Conceptual Relational Database Design Objectives: last revised September 20, 2006 1. To define the concepts functional dependency and multivalued dependency 2. To show how to find the closure

More information

Schema Refinement & Normalization Theory 2. Week 15

Schema Refinement & Normalization Theory 2. Week 15 Schema Refinement & Normalization Theory 2 Week 15 1 How do we know R is in BCNF? If R has only two attributes, then it is in BCNF If F only uses attributes in R, then: R is in BCNF if and only if for

More information

Chapter 3: Relational Model

Chapter 3: Relational Model Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational Calculus Domain Relational Calculus Extended Relational-Algebra-Operations Modification of the Database

More information

CS352 Lecture - Conceptual Relational Database Design

CS352 Lecture - Conceptual Relational Database Design CS352 Lecture - Conceptual Relational Database Design Objectives: last revised September 16, 2004 1. To define the concepts functional dependency and multivalued dependency 2. To show how to find the closure

More information

Part II: Using FD Theory to do Database Design

Part II: Using FD Theory to do Database Design Part II: Using FD Theory to do Database Design 32 Recall that poorly designed table? part manufacturer manaddress seller selleraddress price 1983 Hammers R Us 99 Pinecrest ABC 1229 Bloor W 5.59 8624 Lee

More information

Functional Dependencies

Functional Dependencies Functional Dependencies Meaning of FD s Keys and Superkeys Inferring FD s 1 Motivation Consider the relation: Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) 2 1 Motivation (2) If you know

More information

CS 338 Functional Dependencies

CS 338 Functional Dependencies CS 338 Functional Dependencies Bojana Bislimovska Winter 2016 Outline Design Guidelines for Relation Schemas Functional Dependency Set and Attribute Closure Schema Decomposition Boyce-Codd Normal Form

More information

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section

Lectures 12: Design Theory I. 1. Normal forms & functional dependencies 2/19/2018. Today s Lecture. What you will learn about in this section Today s Lecture Lectures 12: Design Theory I Professor Xiannong Meng Spring 2018 Lecture and activity contents are based on what Prof Chris Ré used in his CS 145 in the fall 2016 term with permission 1.

More information

Theory of Normal Forms Decomposition of Relations. Overview

Theory of Normal Forms Decomposition of Relations. Overview .. Winter 2008 CPE/CSC 366: Database Modeling, Design and Implementation Alexander Dekhtyar.. Overview Theory of Normal Forms Decomposition of Relations Functional Dependencies capture the attribute dependencies

More information

18. Relational Database Design

18. Relational Database Design 18. Relational Database Design The relational datamodel was introduced by Codd in 1970. It is the most widely used datamodel extended with the possibilities of the World Wide Web, because of its simplicity

More information

Lecture 5 Design Theory and Normalization

Lecture 5 Design Theory and Normalization CompSci 516 Data Intensive Computing Systems Lecture 5 Design Theory and Normalization Instructor: Sudeepa Roy Duke CS, Fall 2017 CompSci 516: Database Systems 1 HW1 deadline: Announcements Due on 09/21

More information

Lectures 5 & 6. Lectures 6: Design Theory Part II

Lectures 5 & 6. Lectures 6: Design Theory Part II Lectures 5 & 6 Lectures 6: Design Theory Part II Lecture 6 Today s Lecture 1. Boyce-Codd Normal Form ACTIVITY 2. Decompositions & 3NF ACTIVITY 3. MVDs ACTIVITY 2 Lecture 6 > Section 1 1. Boyce-Codd Normal

More information

DATABASE MANAGEMENT SYSTEM SHORT QUESTIONS. QUESTION 1: What is database?

DATABASE MANAGEMENT SYSTEM SHORT QUESTIONS. QUESTION 1: What is database? DATABASE MANAGEMENT SYSTEM SHORT QUESTIONS Complete book short Answer Question.. QUESTION 1: What is database? A database is a logically coherent collection of data with some inherent meaning, representing

More information

Desirable database characteristics Database design, revisited

Desirable database characteristics Database design, revisited CMPT 354 Desirable database characteristics Database design, revisited Normal Forms First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form Normal forms and functional dependencies

More information

Database Normalization. (Olav Dæhli 2018)

Database Normalization. (Olav Dæhli 2018) Database Normalization (Olav Dæhli 2018) 1 What is normalization and why normalize? Normalization: A set of rules to decompose relations (tables) into smaller relations (tables), without loosing any data

More information