Design of Relational Database Schemas

Size: px
Start display at page:

Download "Design of Relational Database Schemas"

Transcription

1 Design of Relational Database Schemas T. M. Murali October 27, November 1, 2010

2 Plan Till Thanksgiving What are the typical problems or anomalies in relational designs? Introduce the idea of decomposing a relation schema into two smaller schemas. Introduce Boyce-Codd normal form (BCNF), a condition on relational schemas that eliminates anomalies. BCNF stated using the concept of FDs. Use decomposition of schemas to bring them to BCNF. Define another type of constraint called Multivalued Dependencies (MDs). Define normal forms that eliminate MDs.

3 Closures of FDs Given a relation R and a set F of FDs that hold in R the closure {F} + is the set of all FDs that follow from R.

4 Closures of FDs Given a relation R and a set F of FDs that hold in R the closure {F} + is the set of all FDs that follow from R. Recall: An FD S follows from a set of FDs T if every relation instance that satisfies all the FDs in T also satisfies S. S = {A C} follows from T = {A B, B C}.

5 Computing Closures of FDs To compute the closure of a set of FDs, repeatedly apply Armstrong s Axioms until you cannot find any new FDs:

6 Computing Closures of FDs To compute the closure of a set of FDs, repeatedly apply Armstrong s Axioms until you cannot find any new FDs: Reflexivity: If Y X, then X Y Augmentation: If X Y then XZ YZ for any attribute Z. Transitivity: If X Y and Y Z then X Z.

7 Examples of Computing Closures of FDs Let us include only completely non-trivial FDs in these examples, with a single attribute on the right. Assume that there are no attributes other than those mentioned in the FDs. F = {A B, B C}. {F} + is

8 Examples of Computing Closures of FDs Let us include only completely non-trivial FDs in these examples, with a single attribute on the right. Assume that there are no attributes other than those mentioned in the FDs. F = {A B, B C}. {F} + is {A B, B C, A C, AC B, AB C}

9 Examples of Computing Closures of FDs Let us include only completely non-trivial FDs in these examples, with a single attribute on the right. Assume that there are no attributes other than those mentioned in the FDs. F = {A B, B C}. {F} + is {A B, B C, A C, AC B, AB C} F = {AB C, BC A, AC B}. {F} + is

10 Examples of Computing Closures of FDs Let us include only completely non-trivial FDs in these examples, with a single attribute on the right. Assume that there are no attributes other than those mentioned in the FDs. F = {A B, B C}. {F} + is {A B, B C, A C, AC B, AB C} F = {AB C, BC A, AC B}. {F} + is {AB C, BC A, AC B}

11 Examples of Computing Closures of FDs Let us include only completely non-trivial FDs in these examples, with a single attribute on the right. Assume that there are no attributes other than those mentioned in the FDs. F = {A B, B C}. {F} + is {A B, B C, A C, AC B, AB C} F = {AB C, BC A, AC B}. {F} + is {AB C, BC A, AC B} F = {A B, B C, C D}. {F} + is

12 Examples of Computing Closures of FDs Let us include only completely non-trivial FDs in these examples, with a single attribute on the right. Assume that there are no attributes other than those mentioned in the FDs. F = {A B, B C}. {F} + is {A B, B C, A C, AC B, AB C} F = {AB C, BC A, AC B}. {F} + is {AB C, BC A, AC B} F = {A B, B C, C D}. {F} + is {A B, B C, C D, A C, A D, B D,...}

13 Closures of FDs vs. Closures of Attributes Both algorithms take as input a relation R and a set of FDs F. Closure of FDs: Computes {F} +, the set of all FDs that follow from F. Output is a set of FDs. Output may contain an exponential number of FDs. Closure of attributes: In addition, takes a set {A1, A 2,..., A n } of attributes as input. Computes {A1, A 2,..., A n } +, the set of all attributes B such that the A 1 A 2... A n B follows from F. Output is a set of attributes. Output may contain at most the number of attributes in R.

14 Projecting Sets of FDs Suppose we have a relation R and a set of FDs F. Let S be a relation obtained by projecting R into a subset of the attributes of R, i.e., S = π Attributes (R). The projection F S of F is the set of FDs that follow from F and hold in S (involve only attributes of S). Algorithm for computing F S : 1. Compute {F} F S is the set of all FDs in {F} + that involve only the attributes in S. Book describes a different algorithm on page 82 (Chapter 3.2.8). Book s algorithm also shows how to compute a minimal basis of F S.

15 Projecting Sets of FDs Suppose we have a relation R and a set of FDs F. Let S be a relation obtained by projecting R into a subset of the attributes of R, i.e., S = π Attributes (R). The projection F S of F is the set of FDs that follow from F and hold in S (involve only attributes of S). Algorithm for computing F S : 1. Compute {F} F S is the set of all FDs in {F} + that involve only the attributes in S. Book describes a different algorithm on page 82 (Chapter 3.2.8). Book s algorithm also shows how to compute a minimal basis of F S. R(A, B, C, D), F = {A B, B C, C D}. Which FDs hold in S(A, C, D)?

16 Projecting Sets of FDs Suppose we have a relation R and a set of FDs F. Let S be a relation obtained by projecting R into a subset of the attributes of R, i.e., S = π Attributes (R). The projection F S of F is the set of FDs that follow from F and hold in S (involve only attributes of S). Algorithm for computing F S : 1. Compute {F} F S is the set of all FDs in {F} + that involve only the attributes in S. Book describes a different algorithm on page 82 (Chapter 3.2.8). Book s algorithm also shows how to compute a minimal basis of F S. R(A, B, C, D), F = {A B, B C, C D}. Which FDs hold in S(A, C, D)? {F} + is

17 Projecting Sets of FDs Suppose we have a relation R and a set of FDs F. Let S be a relation obtained by projecting R into a subset of the attributes of R, i.e., S = π Attributes (R). The projection F S of F is the set of FDs that follow from F and hold in S (involve only attributes of S). Algorithm for computing F S : 1. Compute {F} F S is the set of all FDs in {F} + that involve only the attributes in S. Book describes a different algorithm on page 82 (Chapter 3.2.8). Book s algorithm also shows how to compute a minimal basis of F S. R(A, B, C, D), F = {A B, B C, C D}. Which FDs hold in S(A, C, D)? {F} + is {A B, B C, C D, A C, A D, B D}

18 Projecting Sets of FDs Suppose we have a relation R and a set of FDs F. Let S be a relation obtained by projecting R into a subset of the attributes of R, i.e., S = π Attributes (R). The projection F S of F is the set of FDs that follow from F and hold in S (involve only attributes of S). Algorithm for computing F S : 1. Compute {F} F S is the set of all FDs in {F} + that involve only the attributes in S. Book describes a different algorithm on page 82 (Chapter 3.2.8). Book s algorithm also shows how to compute a minimal basis of F S. R(A, B, C, D), F = {A B, B C, C D}. Which FDs hold in S(A, C, D)? {F} + is {A B, B C, C D, A C, A D, B D} F S is {C D, A C, A D}.

19 Design of Relational Database Schemas Careless design of relational schemas can cause problems. Example: Combining the relation for a many-many relationship with the relation for one of its entity sets causes redundancy.

20 Design of Relational Database Schemas Careless design of relational schemas can cause problems. Example: Combining the relation for a many-many relationship with the relation for one of its entity sets causes redundancy. Suppose we combine the schemas Courses(Number, DepartmentName, CourseName, Classroom, Enrollment) and Take(StudentName, Address, Number, DepartmentName) into one relation Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address).

21 Anomalies in Relational Schemas Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address)

22 Anomalies in Relational Schemas Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) Redundancy: information is repeated unnecessarily in several tuples. Update anomalies: We change information in one tuple but leave the old information in another tuple. Insertion anomalies: It is not possible to store some information unless some other, unrelated information is stored as well. Deletion anomalies: If a set of values becomes empty, we may lose other information as a side effect.

23 Decomposing Relations Accepted way to eliminate anomalies is to decompose relations. Given a relation R(A 1, A 2,..., A n ), two relations S(B 1, B 2,..., B m ) and T (C 1, C 2,..., C k ) form a decomposition of R if 1. the attributes of S and T together make up the attributes of R, i.e., {A 1, A 2,..., A n } = {B 1, B 2,..., B m } {C 1, C 2,..., C k }. 2. the tuples in S are the projections into {B 1, B 2,..., B m } of the tuples in R, i.e. S π B1,B 2,...,B m (R). 3. the tuples in T are the projections into {C 1, C 2,..., C k } of the tuples in R, i.e., T π C1,C 2,...,C k (R).

24 Example of Decomposition Decompose Courses into Courses1(Number, DepartmentName, CourseName, Classroom, Enrollment) and Courses2(Number, DepartmentName, StudentName, Address). Are the anomalies removed? Redundancy Update Insertion Deletion

25 Boyce-Codd Normal Form Condition on the FDs in a relation that guarantees that anomalies do not exist.

26 Boyce-Codd Normal Form Condition on the FDs in a relation that guarantees that anomalies do not exist. A relation R is in Boyce-Codd Normal Form (BCNF) if and only if for every non-trivial FD A 1 A 2... A n B for R, {A 1, A 2,..., A n } is a superkey for R. Informally, the left side of every non-trivial FD must be a superkey. A relation R violates BCNF if it has an FD such that the attributes of the left side of an FD do not form a superkey. In other words, there is some key of R such that only some (not all) of the attributes in this key appear on the left side of the FD.

27 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey.

28 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys!

29 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF?

30 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF? FDs are

31 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF? FDs are Number DepartmentName CourseName Number DepartmentName Classroom Number DepartmentName Enrollment

32 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF? FDs are Number DepartmentName CourseName Number DepartmentName Classroom Number DepartmentName Enrollment What is {Number, DepartmentName} +?

33 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF? FDs are Number DepartmentName CourseName Number DepartmentName Classroom Number DepartmentName Enrollment What is {Number, DepartmentName} +? {Number, DepartmentName, Coursename, Classroom, Enrollment}.

34 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF? FDs are Number DepartmentName CourseName Number DepartmentName Classroom Number DepartmentName Enrollment What is {Number, DepartmentName} +? {Number, DepartmentName, Coursename, Classroom, Enrollment}. Therefore, the key is {Number, DepartmentName, StudentName, Address}.

35 Checking for BCNF Violations 1. List all FDs. 2. Ensure that left hand side of each FD is a superkey. We have to first find all the keys! Is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address) in BCNF? FDs are Number DepartmentName CourseName Number DepartmentName Classroom Number DepartmentName Enrollment What is {Number, DepartmentName} +? {Number, DepartmentName, Coursename, Classroom, Enrollment}. Therefore, the key is {Number, DepartmentName, StudentName, Address}. The relation is not in BCNF.

36 Decomposition into BCNF Suppose R is a relation schema that violates BCNF. We can decompose R into a set S of new relations such that 1. each relation in S is in BCNF and 2. we can recover R from the relations in S, i.e., we can reconstruct R exactly from the relations in S.

37 BCNF Normalisation Algorithm Let A be the set of all attributes of R. Let F be the set of all FDs of R. Suppose the FD X 1 X 2... X m Y violates BCNF.

38 BCNF Normalisation Algorithm Let A be the set of all attributes of R. Let F be the set of all FDs of R. Suppose the FD X 1 X 2... X m Y violates BCNF. 1. Compute {X 1 X 2..., X m } +.

39 BCNF Normalisation Algorithm Let A be the set of all attributes of R. Let F be the set of all FDs of R. Suppose the FD X 1 X 2... X m Y violates BCNF. 1. Compute {X 1 X 2..., X m } Decompose R into two relations R 1 and R 2 with schemas R 1 : all the attributes in {X 1, X 2..., X m } + R 2 : all the attributes on the left side of the violating FD and all the attributes of R not in {X 1, X 2,..., X m } +, i.e., A {X 1, X 2..., X m } + {X 1, X 2..., X m }.

40 BCNF Normalisation Algorithm Let A be the set of all attributes of R. Let F be the set of all FDs of R. Suppose the FD X 1 X 2... X m Y violates BCNF. 1. Compute {X 1 X 2..., X m } Decompose R into two relations R 1 and R 2 with schemas R 1 : all the attributes in {X 1, X 2..., X m } + R 2 : all the attributes on the left side of the violating FD and all the attributes of R not in {X 1, X 2,..., X m } +, i.e., A {X 1, X 2..., X m } + {X 1, X 2..., X m }. 3. Find FDs in R 1 and R 2 and decompose them if they are not in BCNF 4. For i = 1, 2 Compute F Ri the projection of the FDs in F into R i. If any of the FDs in F Ri violates BCNF, decompose R i recursively.

41 Decomposing Courses Schema is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address). BCNF-violating FD is Number DepartmentName CourseName Classroom Enrollment.

42 Decomposing Courses Schema is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address). BCNF-violating FD is Number DepartmentName CourseName Classroom Enrollment. What is {Number, DepartmentName} +?

43 Decomposing Courses Schema is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address). BCNF-violating FD is Number DepartmentName CourseName Classroom Enrollment. What is {Number, DepartmentName} +? {Number, DepartmentName, CourseName, Classroom, Enrollment

44 Decomposing Courses Schema is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address). BCNF-violating FD is Number DepartmentName CourseName Classroom Enrollment. What is {Number, DepartmentName} +? {Number, DepartmentName, CourseName, Classroom, Enrollment Decompose Courses into Courses1(Number, DepartmentName, CourseName, Classroom, Enrollment) and Courses2(Number, DepartmentName, StudentName, Address).

45 Decomposing Courses Schema is Courses(Number, DepartmentName, CourseName, Classroom, Enrollment, StudentName, Address). BCNF-violating FD is Number DepartmentName CourseName Classroom Enrollment. What is {Number, DepartmentName} +? {Number, DepartmentName, CourseName, Classroom, Enrollment Decompose Courses into Courses1(Number, DepartmentName, CourseName, Classroom, Enrollment) and Courses2(Number, DepartmentName, StudentName, Address). Are there any BCNF violations in the two new relations?

46 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId)

47 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName

48 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key?

49 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}.

50 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation?

51 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation? Yes.

52 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation? Yes. Use ID Name FavouriteAdvisorId to decompose.

53 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation? Yes. Use ID Name FavouriteAdvisorId to decompose. {ID} + is

54 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation? Yes. Use ID Name FavouriteAdvisorId to decompose. {ID} + is {ID, Name, FavouriteAdvisorId}.

55 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation? Yes. Use ID Name FavouriteAdvisorId to decompose. {ID} + is {ID, Name, FavouriteAdvisorId}. Schemas for new relations are

56 Another Example of Decomposition (1) Schema is Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) What are the FDs? ID Name FavouriteAdvisorId AdvisorId AdvisorName What is the key? {ID, AdvisorId}. Is there a BCNF violation? Yes. Use ID Name FavouriteAdvisorId to decompose. {ID} + is {ID, Name, FavouriteAdvisorId}. Schemas for new relations are Students1(ID, Name, FavouriteAdvisorId) Students2(ID, AdvisorId, AdvisorName)

57 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)?

58 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF.

59 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF. What are the FDs in Students2(ID, AdvisorId, AdvisorName)?

60 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF. What are the FDs in Students2(ID, AdvisorId, AdvisorName)? AdvisorId AdvisorName Does it violate BCNF?

61 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF. What are the FDs in Students2(ID, AdvisorId, AdvisorName)? AdvisorId AdvisorName Does it violate BCNF? Yes. Repeat the decomposition process. Use AdvisorId AdvisorName to decompose. {AdvisorId} + is

62 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF. What are the FDs in Students2(ID, AdvisorId, AdvisorName)? AdvisorId AdvisorName Does it violate BCNF? Yes. Repeat the decomposition process. Use AdvisorId AdvisorName to decompose. {AdvisorId} + is {AdvisorId, AdvisorName}.

63 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF. What are the FDs in Students2(ID, AdvisorId, AdvisorName)? AdvisorId AdvisorName Does it violate BCNF? Yes. Repeat the decomposition process. Use AdvisorId AdvisorName to decompose. {AdvisorId} + is {AdvisorId, AdvisorName}. Schemas for new relations are

64 Another Example of Decomposition (2) What are the FDs in Student1(ID, Name, FavouriteAdvisorId)? There are none that violate BCNF. What are the FDs in Students2(ID, AdvisorId, AdvisorName)? AdvisorId AdvisorName Does it violate BCNF? Yes. Repeat the decomposition process. Use AdvisorId AdvisorName to decompose. {AdvisorId} + is {AdvisorId, AdvisorName}. Schemas for new relations are Students2(ID, AdvisorId) Students3(AdvisorId, AdvisorName).

65 Examples (Problem 1 of Handout 3) Apply the BCNF normalisation algorithm to Inventory relation. (Problem 2 of Handout 3) Apply the BCNF normalisation algorithm to Concerts relation. For both problems, try all possible choices of FDs to start the normalisation with. Compare the advantages and disadvantages of the choices.

66 BCNFs and Two-Attribute Relations True or False: Every two-attribute relation R(A, B) is in BCNF.

67 BCNFs and Two-Attribute Relations True or False: Every two-attribute relation R(A, B) is in BCNF. The statement is true. Why?

68 BCNFs and Two-Attribute Relations True or False: Every two-attribute relation R(A, B) is in BCNF. The statement is true. Why? Consider four possible cases: 1. There are no non-trivial FDs. 2. A B is the only non-trivial FD. 3. B A is the only non-trivial FD. 4. Both A B and B A hold in R.

69 Decomposition into BCNF Suppose R is a relation schema that violates BCNF. We can decompose R into a set S of two or more new relations such that 1. each relation in S is in BCNF and 2. we can recover R from the relations in S, i.e., we can reconstruct R from the relations in S. How does the normalisation algorithm guarantee the second condition? In general, what properties does the decomposition satisfy?

70 Desirable Properties of a Decomposition 1. Eliminate anomalies. 2. Recover the original relation exactly from the relations it is decomposed into. 3. When we reconstruct the original relation, the result will satisfy the original FDs.

71 Desirable Properties of a Decomposition 1. Eliminate anomalies. 2. Recover the original relation exactly from the relations it is decomposed into. 3. When we reconstruct the original relation, the result will satisfy the original FDs. BCNF decomposition algorithm:

72 Desirable Properties of a Decomposition 1. Eliminate anomalies. 2. Recover the original relation exactly from the relations it is decomposed into. 3. When we reconstruct the original relation, the result will satisfy the original FDs. BCNF decomposition algorithm: gives us properties 1 and 2 but not 3. 3NF decomposition algorithm: gives us properties 2 and 3 but not 1. (Discuss in the next class.)

73 Candidate Normalisation Algorithm Every two-attribute relation is in BCNF.

74 Candidate Normalisation Algorithm Every two-attribute relation is in BCNF. Can we bring any relation R into BCNF by arbitrarily decomposing it into two-attribute relations?

75 Candidate Normalisation Algorithm Every two-attribute relation is in BCNF. Can we bring any relation R into BCNF by arbitrarily decomposing it into two-attribute relations? No, since we may not be able to recover R correctly from the decomposition.

76 Joining Relations R A B a 1 b 1 a 2 b 1 a 2 b 2 S B C b 1 c 1 b 2 c 2 b 2 c 3 = T A B C a 1 b 1 c 1 a 2 b 1 c 1 a 2 b 2 c 2 a 2 b 2 c 3 Let R and S be two relations with one common attribute B. Relation T is the natural join of R and S, denoted R S if and only if

77 Joining Relations R A B a 1 b 1 a 2 b 1 a 2 b 2 S B C b 1 c 1 b 2 c 2 b 2 c 3 = T A B C a 1 b 1 c 1 a 2 b 1 c 1 a 2 b 2 c 2 a 2 b 2 c 3 Let R and S be two relations with one common attribute B. Relation T is the natural join of R and S, denoted R S if and only if the attributes of T are the union of the attributes of R and S,

78 Joining Relations R A B a 1 b 1 a 2 b 1 a 2 b 2 S B C b 1 c 1 b 2 c 2 b 2 c 3 = T A B C a 1 b 1 c 1 a 2 b 1 c 1 a 2 b 2 c 2 a 2 b 2 c 3 Let R and S be two relations with one common attribute B. Relation T is the natural join of R and S, denoted R S if and only if the attributes of T are the union of the attributes of R and S, every tuple t T is the join of two tuples r R and s S that agree on the attribute B, i.e., t agrees with r on all the attributes in R and with s on all attributes in S,

79 Joining Relations R A B a 1 b 1 a 2 b 1 a 2 b 2 S B C b 1 c 1 b 2 c 2 b 2 c 3 = T A B C a 1 b 1 c 1 a 2 b 1 c 1 a 2 b 2 c 2 a 2 b 2 c 3 Let R and S be two relations with one common attribute B. Relation T is the natural join of R and S, denoted R S if and only if the attributes of T are the union of the attributes of R and S, every tuple t T is the join of two tuples r R and s S that agree on the attribute B, i.e., t agrees with r on all the attributes in R and with s on all attributes in S, T contains all tuples formed in this manner.

80 Recovering Information from a Decomposition Suppose R is a relation schema that violates BCNF. The BCNF decomposition algorithm decomposes R into a set {S 1, S 2,... S k } of new relations such that 1. each relation S i, 1 i k is in BCNF and 2. the decomposition of R into {S 1, S 2,... S k } is a lossless-join decomposition, i.e., R = S 1 S 2... S k.

81 Recovering Information from a Decomposition Suppose R is a relation schema that violates BCNF. The BCNF decomposition algorithm decomposes R into a set {S 1, S 2,... S k } of new relations such that 1. each relation S i, 1 i k is in BCNF and 2. the decomposition of R into {S 1, S 2,... S k } is a lossless-join decomposition, i.e., R = S 1 S 2... S k. 2.1 Every tuple in R is a tuple in S 1 S 2... S k. 2.2 Every tuple in S 1 S 2... S k is in R.

82 Example of Lossless-Join Decomposition Relation schema is R(A, B, C). FD is B C.

83 Example of Lossless-Join Decomposition Relation schema is R(A, B, C). FD is B C. Relations in BCNF are S(A, B) and T (B, C).

84 Example of Lossless-Join Decomposition Relation schema is R(A, B, C). FD is B C. Relations in BCNF are S(A, B) and T (B, C). Prove that R = S T 1. Every tuple in R is in S T. 2. Every tuple in S T is in R.

85 Example of Lossless-Join Decomposition Relation schema is R(A, B, C). FD is B C. Relations in BCNF are S(A, B) and T (B, C). Prove that R = S T 1. Every tuple in R is in S T. 2. Every tuple in S T is in R. What if FD were A C and we decomposed R into S and T as above?

86 Example of Lossless-Join Decomposition Relation schema is R(A, B, C). FD is B C. Relations in BCNF are S(A, B) and T (B, C). Prove that R = S T 1. Every tuple in R is in S T. 2. Every tuple in S T is in R. What if FD were A C and we decomposed R into S and T as above? S T contains tuples not in R! In general, if R s attributes are X Y Z and Y Z holds in R, then R = π X Y (R) π Y Z (R).

87 The Chase Test for Lossless Join Suppose we have a relation R, a set F of FDs that hold in R, and a decomposition of R into relations S 1, S 2,..., S k. We have forgotten how we decomposed R. Is there a way to check R equals the natural join of S 1, S 2,..., S k? 1. Every tuple in R is a tuple in S 1 S 2... S k. 2. Every tuple in S 1 S 2... S k is in R.

88 The Chase Test for Lossless Join Suppose we have a relation R, a set F of FDs that hold in R, and a decomposition of R into relations S 1, S 2,..., S k. We have forgotten how we decomposed R. Is there a way to check R equals the natural join of S 1, S 2,..., S k? 1. Every tuple in R is a tuple in S 1 S 2... S k. 2. Every tuple in S 1 S 2... S k is in R. R S A B C D A 1 S 2 S 3 S 1 S 2 S 3 D A C B C D A B C D

89 The Chase Test for Lossless Join S R A B C D A 1 S 2 S 3 S 1 S 2 S 3 D A C B C D A B C D t 1. Natural join is associate and commutative: For each tuple t in S 1 S 2... S k, projection of t into S i is a tuple in π Si (R), for every 1 i k.

90 u The Chase Test for Lossless Join S R A B C D A 1 S 2 S 3 S 1 S 2 S 3 D A C B C D A B C D u 1. Natural join is associate and commutative: For each tuple t in S 1 S 2... S k, projection of t into S i is a tuple in π Si (R), for every 1 i k. 2. Every tuple u in R is surely in π S1 (R) π S2 (R)... π Sk (R).

91 t The Chase Test for Lossless Join S R A B C D A 1 S 2 S 3 S 1 S 2 S 3 D A C B C D A B C D t 1. Natural join is associate and commutative: For each tuple t in S 1 S 2... S k, projection of t into S i is a tuple in π Si (R), for every 1 i k. 2. Every tuple u in R is surely in π S1 (R) π S2 (R)... π Sk (R). 3. How can we show that if the FDs in F hold in R, then every tuple in π S1 (R) π S2 (R)... π Sk (R) is also a tuple in R? Use the Chase test.

92 t 1 t 2 Steps in Chase Test S R A B C D A 1 S 2 S 3 S 1 S 2 S 3 D A C B C D A B C D t t 3 If a tuple t is in π S1(R) π S2(R)... π Sk (R), then there must be tuples t1, t 2,... t k in R such that t is the join of the projections of t i into S i, for every 1 i k. each ti agrees with t in the attributes in S i but has unknown values for the attributes not in S i. Using the FDs in F, we want to prove that t must be equal to some t i.

93 t 1 t 2 Steps in Chase Test S R A B C D A 1 S 2 S 3 S 1 S 2 S 3 D A C B C D A B C D t t 3 If a tuple t is in π S1(R) π S2(R)... π Sk (R), then there must be tuples t1, t 2,... t k in R such that t is the join of the projections of t i into S i, for every 1 i k. each ti agrees with t in the attributes in S i but has unknown values for the attributes not in S i. Using the FDs in F, we want to prove that t must be equal to some t i. 1. Draw a tableau to indicate which attributes we know the values of in the tuples t 1, t 2,... t k. 2. Use FDs to equate unknown attributes of these tuples. 3. When no FD can be applied, check if t is one of the tuples in the tableau.

94 Example of Chase Test Work out following two cases: 1. Decomposition of R(A, B, C, D) into S 1 (A, D), S 2 (A, C) and S 3 (B, C, D) with FDs A B, B C, and CD A. 2. Same decomposition with FD B AD Work out examples in Handout 3: 1. (Problem 1, part 6) Apply Chase test to decomposition of Inventory into Inventory1 and Inventory2. 2. (Problem 1, part 7) Modify one of the attributes in either Inventory1 or Inventory2 to obtain a lossless-join decomposition. Verify using the chase test. 3. (Problem 2, part 8(ii)) Apply Chase test to decomposition of Concerts into Concerts1 and Concerts2. 4. Apply Chase test to decomposition of Concerts into Concerts1 and Concerts3(City, Song, Album) and Concerts4(City, Year).

Database Design and Normalization

Database Design and Normalization Database Design and Normalization CPS352: Database Systems Simon Miner Gordon College Last Revised: 9/27/12 Agenda Check-in Functional Dependencies (continued) Design Project E-R Diagram Presentations

More information

Relational Database Design

Relational Database Design Relational Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design schema in appropriate

More information

Relational Database Design Theory

Relational Database Design Theory Relational Database Design Theory Informal guidelines for good relational designs Functional dependencies Normal forms and normalization 1NF, 2NF, 3NF BCNF, 4NF, 5NF Inference rules on functional dependencies

More information

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Schema Design and Normal Forms Sid Name Level Rating Wage Hours Entity-Relationship Diagram Schema Design and Sid Name Level Rating Wage Hours Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke 1 Database Management Systems, 2 nd Edition. R. Ramakrishnan

More information

Database Design and Normal Forms

Database Design and Normal Forms Database Design and Normal Forms Database Design coming up with a good schema is very important How do we characterize the goodness of a schema? If two or more alternative schemas are available how do

More information

Chapter 10. Functional Dependencies and Normalization for Relational Databases

Chapter 10. 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

Schema Refinement and Normalization

Schema Refinement and Normalization Schema Refinement and Normalization Module 5, Lectures 3 and 4 Database Management Systems, R. Ramakrishnan 1 The Evils of Redundancy Redundancy is at the root of several problems associated with relational

More information

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31 Databases -Normalization III (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31 This lecture This lecture describes 3rd normal form. (N Spadaccini 2010 and W Liu 2012) Databases -

More information

Lecture Notes on Database Normalization

Lecture Notes on Database Normalization Lecture Notes on Database Normalization Chengkai Li Department of Computer Science and Engineering The University of Texas at Arlington April 15, 2012 I decided to write this document, because many students

More information

Relational Database Design: FD s & BCNF

Relational Database Design: FD s & BCNF CS145 Lecture Notes #5 Relational Database Design: FD s & BCNF Motivation Automatic translation from E/R or ODL may not produce the best relational design possible Sometimes database designers like to

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

Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12

Theory behind Normalization & DB Design. Satisfiability: Does an FD hold? Lecture 12 Theory behind Normalization & DB Design Lecture 12 Satisfiability: Does an FD hold? Satisfiability of FDs Given: FD X Y and relation R Output: Does R satisfy X Y? Algorithm: a.sort R on X b.do all the

More information

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1 COSC344 Database Theory and Applications Lecture 9 Normalisation COSC344 Lecture 9 1 Overview Last Lecture Functional Dependencies This Lecture Normalisation Introduction 1NF 2NF 3NF BCNF Source: Section

More information

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme Goals: Suppose we have a db scheme: is it good? Suppose we have a db scheme derived from an ER diagram: is it good? define precise notions of the qualities of a relational database scheme define algorithms

More information

Theory of Relational Database Design and Normalization

Theory of Relational Database Design and Normalization Theory of Relational Database Design and Normalization (Based on Chapter 14 and some part of Chapter 15 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3) 1 Informal Design Guidelines for

More information

Schema Refinement, Functional Dependencies, Normalization

Schema Refinement, Functional Dependencies, Normalization Schema Refinement, Functional Dependencies, Normalization MSCI 346: Database Systems Güneş Aluç, University of Waterloo Spring 2015 MSCI 346: Database Systems Chapter 19 1 / 42 Outline 1 Introduction Design

More information

Chapter 7: Relational Database Design

Chapter 7: Relational Database Design Chapter 7: Relational Database Design Pitfalls in Relational Database Design Decomposition Normalization Using Functional Dependencies Normalization Using Multivalued Dependencies Normalization Using Join

More information

CS143 Notes: Normalization Theory

CS143 Notes: Normalization Theory CS143 Notes: Normalization Theory Book Chapters (4th) Chapters 7.1-6, 7.8, 7.10 (5th) Chapters 7.1-6, 7.8 (6th) Chapters 8.1-6, 8.8 INTRODUCTION Main question How do we design good tables for a relational

More information

Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354 Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354 1. [10] Show that each of the following are not valid rules about FD s by giving a small example relations that satisfy the given

More information

Chapter 8. Database Design II: Relational Normalization Theory

Chapter 8. Database Design II: Relational Normalization Theory Chapter 8 Database Design II: Relational Normalization Theory The E-R approach is a good way to start dealing with the complexity of modeling a real-world enterprise. However, it is only a set of guidelines

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

Database Management Systems. Redundancy and Other Problems. Redundancy

Database Management Systems. Redundancy and Other Problems. Redundancy Database Management Systems Winter 2004 CMPUT 391: Database Design Theory or Relational Normalization Theory Dr. Osmar R. Zaïane Lecture 2 Limitations of Relational Database Designs Provides a set of guidelines,

More information

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy Week 11: Normal Forms Database Design Database Redundancies and Anomalies Functional Dependencies Entailment, Closure and Equivalence Lossless Decompositions The Third Normal Form (3NF) The Boyce-Codd

More information

Functional Dependencies and Normalization

Functional Dependencies and Normalization Functional Dependencies and Normalization 5DV119 Introduction to Database Management Umeå University Department of Computing Science Stephen J. Hegner [email protected] http://www.cs.umu.se/~hegner Functional

More information

Introduction to Database Systems. Normalization

Introduction to Database Systems. Normalization Introduction to Database Systems Normalization Werner Nutt 1 Normalization 1. Anomalies 1. Anomalies 2. Boyce-Codd Normal Form 3. 3 rd Normal Form 2 Anomalies The goal of relational schema design is to

More information

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third Normal Forms For more

More information

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.) Why Is This Important? Schema Refinement and Normal Forms Chapter 19 Many ways to model a given scenario in a database How do we find the best one? We will discuss objective criteria for evaluating database

More information

Advanced Relational Database Design

Advanced Relational Database Design APPENDIX B Advanced Relational Database Design In this appendix we cover advanced topics in relational database design. We first present the theory of multivalued dependencies, including a set of sound

More information

Functional Dependencies

Functional Dependencies BCNF and 3NF Functional Dependencies Functional dependencies: modeling constraints on attributes stud-id name address course-id session-id classroom instructor Functional dependencies should be obtained

More information

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Chapter 10 Functional Dependencies and Normalization for Relational Databases Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright 2004 Pearson Education, Inc. Chapter Outline 1 Informal Design Guidelines for Relational Databases 1.1Semantics of

More information

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Outline Informal Design Guidelines

More information

Database Constraints and Design

Database Constraints and Design Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of

More information

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example

Limitations of E-R Designs. Relational Normalization Theory. Redundancy and Other Problems. Redundancy. Anomalies. Example Limitations of E-R Designs Relational Normalization Theory Chapter 6 Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Normalization

More information

Database Management System

Database Management System UNIT -6 Database Design Informal Design Guidelines for Relation Schemas; Functional Dependencies; Normal Forms Based on Primary Keys; General Definitions of Second and Third Normal Forms; Boyce-Codd Normal

More information

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015 6. Normalization Stéphane Bressan January 28, 2015 1 / 42 This lecture is based on material by Professor Ling Tok Wang. CS 4221: Database Design The Relational Model Ling Tok Wang National University of

More information

DATABASE NORMALIZATION

DATABASE NORMALIZATION DATABASE NORMALIZATION Normalization: process of efficiently organizing data in the DB. RELATIONS (attributes grouped together) Accurate representation of data, relationships and constraints. Goal: - Eliminate

More information

Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations

Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations Normalisation Why normalise? To improve (simplify) database design in order to Avoid update problems Avoid redundancy Simplify update operations 1 Example ( the practical difference between a first normal

More information

Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies

Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies Objectives of Database Design Functional Dependencies 1st Normal Form Decomposition Boyce-Codd Normal Form 3rd Normal Form Multivalue Dependencies 4th Normal Form General view over the design process 1

More information

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 5: Normalization II; Database design case studies. September 26, 2005 Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 5: Normalization II; Database design case studies September 26, 2005 Lecturer: Rasmus Pagh Today s lecture Normalization II: 3rd

More information

Theory of Relational Database Design and Normalization

Theory of Relational Database Design and Normalization Theory of Relational Database Design and Normalization (Based on Chapter 14 and some part of Chapter 15 in Fundamentals of Database Systems by Elmasri and Navathe) 1 Informal Design Guidelines for Relational

More information

Database Design and Normalization

Database Design and Normalization Database Design and Normalization Chapter 10 (Week 11) EE562 Slides and Modified Slides from Database Management Systems, R. Ramakrishnan 1 Computing Closure F + Example: List all FDs with: - a single

More information

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010 Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010 Student Name: ID: Part 1: Multiple-Choice Questions (17 questions, 1

More information

Limitations of DB Design Processes

Limitations of DB Design Processes Normalization CS 317/387 1 Limitations of DB Design Processes Provides a set of guidelines, does not result in a unique database schema Does not provide a way of evaluating alternative schemas Pitfalls:

More information

How To Find Out What A Key Is In A Database Engine

How To Find Out What A Key Is In A Database Engine Database design theory, Part I Functional dependencies Introduction As we saw in the last segment, designing a good database is a non trivial matter. The E/R model gives a useful rapid prototyping tool,

More information

RELATIONAL DATABASE DESIGN

RELATIONAL DATABASE DESIGN RELATIONAL DATABASE DESIGN g Good database design - Avoiding anomalies g Functional Dependencies g Normalization & Decomposition Using Functional Dependencies g 1NF - Atomic Domains and First Normal Form

More information

Relational Normalization Theory (supplemental material)

Relational Normalization Theory (supplemental material) Relational Normalization Theory (supplemental material) CSE 532, Theory of Database Systems Stony Brook University http://www.cs.stonybrook.edu/~cse532 2 Quiz 8 Consider a schema S with functional dependencies:

More information

Design Theory for Relational Databases: Functional Dependencies and Normalization

Design Theory for Relational Databases: Functional Dependencies and Normalization Design Theory for Relational Databases: Functional Dependencies and Normalization Juliana Freire Some slides adapted from L. Delcambre, R. Ramakrishnan, G. Lindstrom, J. Ullman and Silberschatz, Korth

More information

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B. Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Chapter Outline 1 Informal Design Guidelines for Relational Databases

More information

Normalization in Database Design

Normalization in Database Design in Database Design Marek Rychly [email protected] Strathmore University, @ilabafrica & Brno University of Technology, Faculty of Information Technology Advanced Databases and Enterprise Systems 14

More information

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints DBS Database Systems Designing Relational Databases Peter Buneman 12 October 2010 SQL DDL In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table.

More information

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES 1 Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES INFORMAL DESIGN GUIDELINES FOR RELATION SCHEMAS We discuss four informal measures of quality for relation schema design in

More information

Functional Dependency and Normalization for Relational Databases

Functional Dependency and Normalization for Relational Databases Functional Dependency and Normalization for Relational Databases Introduction: Relational database design ultimately produces a set of relations. The implicit goals of the design activity are: information

More information

Normalization of Database

Normalization of Database Normalization of Database UNIT-4 Database Normalisation is a technique of organizing the data in the database. Normalization is a systematic approach of decomposing tables to eliminate data redundancy

More information

Database Systems Concepts, Languages and Architectures

Database Systems Concepts, Languages and Architectures These slides are for use with Database Systems Concepts, Languages and Architectures Paolo Atzeni Stefano Ceri Stefano Paraboschi Riccardo Torlone To view these slides on-screen or with a projector use

More information

Boyce-Codd Normal Form

Boyce-Codd Normal Form 4NF Boyce-Codd Normal Form A relation schema R is in BCNF if for all functional dependencies in F + of the form α β at least one of the following holds α β is trivial (i.e., β α) α is a superkey for R

More information

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University CS 377 Database Systems Database Design Theory and Normalization Li Xiong Department of Mathematics and Computer Science Emory University 1 Relational database design So far Conceptual database design

More information

CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization

CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization CSCI-GA.2433-001 Database Systems Lecture 7: Schema Refinement and Normalization Mohamed Zahran (aka Z) [email protected] http://www.mzahran.com View 1 View 2 View 3 Conceptual Schema At that point we

More information

Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi

Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi Normalization of database model Pazmany Peter Catholic University 2005 Zoltan Fodroczi Closure of an attribute set Given a set of attributes α define the closure of attribute set α under F (denoted as

More information

Relational Normalization: Contents. Relational Database Design: Rationale. Relational Database Design. Motivation

Relational Normalization: Contents. Relational Database Design: Rationale. Relational Database Design. Motivation Relational Normalization: Contents Motivation Functional Dependencies First Normal Form Second Normal Form Third Normal Form Boyce-Codd Normal Form Decomposition Algorithms Multivalued Dependencies and

More information

Graham Kemp (telephone 772 54 11, room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

Graham Kemp (telephone 772 54 11, room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00. CHALMERS UNIVERSITY OF TECHNOLOGY Department of Computer Science and Engineering Examination in Databases, TDA357/DIT620 Tuesday 17 December 2013, 14:00-18:00 Examiner: Results: Exam review: Grades: Graham

More information

Normalization. CIS 331: Introduction to Database Systems

Normalization. CIS 331: Introduction to Database Systems Normalization CIS 331: Introduction to Database Systems Normalization: Reminder Why do we need to normalize? To avoid redundancy (less storage space needed, and data is consistent) To avoid update/delete

More information

Determination of the normalization level of database schemas through equivalence classes of attributes

Determination of the normalization level of database schemas through equivalence classes of attributes Computer Science Journal of Moldova, vol.17, no.2(50), 2009 Determination of the normalization level of database schemas through equivalence classes of attributes Cotelea Vitalie Abstract In this paper,

More information

An Algorithmic Approach to Database Normalization

An Algorithmic Approach to Database Normalization An Algorithmic Approach to Database Normalization M. Demba College of Computer Science and Information Aljouf University, Kingdom of Saudi Arabia [email protected] ABSTRACT When an attempt is made to

More information

MCQs~Databases~Relational Model and Normalization http://en.wikipedia.org/wiki/database_normalization

MCQs~Databases~Relational Model and Normalization http://en.wikipedia.org/wiki/database_normalization http://en.wikipedia.org/wiki/database_normalization Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy. Normalization usually involves

More information

A Web-Based Environment for Learning Normalization of Relational Database Schemata

A Web-Based Environment for Learning Normalization of Relational Database Schemata A Web-Based Environment for Learning Normalization of Relational Database Schemata Nikolay Georgiev September 2008 Master s Thesis in Computing Science, 30 ECTS credits Supervisor at CS-UmU: Stephen J.

More information

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3) Announcements IT0: Database Management and Organization Normalization (Chapter 3) Department coin design contest deadline - February -week exam Monday, February 1 Lab SQL SQL Server: ALTER TABLE tname

More information

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks] EXAMINATIONS 2005 MID-YEAR COMP 302 Database Systems Time allowed: Instructions: 3 Hours Answer all questions. Make sure that your answers are clear and to the point. Write your answers in the spaces provided.

More information

Normalisation and Data Storage Devices

Normalisation and Data Storage Devices Unit 4 Normalisation and Data Storage Devices Structure 4.1 Introduction 4.2 Functional Dependency 4.3 Normalisation 4.3.1 Why do we Normalize a Relation? 4.3.2 Second Normal Form Relation 4.3.3 Third

More information

Normalisation in the Presence of Lists

Normalisation in the Presence of Lists 1 Normalisation in the Presence of Lists Sven Hartmann, Sebastian Link Information Science Research Centre, Massey University, Palmerston North, New Zealand 1. Motivation & Revision of the RDM 2. The Brouwerian

More information

6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization 6.830 Lecture 3 9.16.2015 PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization Animals(name,age,species,cageno,keptby,feedtime) Keeper(id,name)

More information

C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London.. 1 21.01 20 2 23.01 2 Martin Paris.. 1 26.10 25 3 Deen London.. 2 29.

C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London.. 1 21.01 20 2 23.01 2 Martin Paris.. 1 26.10 25 3 Deen London.. 2 29. 4. Normalisation 4.1 Introduction Suppose we are now given the task of designing and creating a database. How do we produce a good design? What relations should we have in the database? What attributes

More information

Normalization for Relational DBs

Normalization for Relational DBs Chapter 7 Functional Dependencies & Normalization for Relational DBs Truong Quynh Chi [email protected] Spring- 2013 Top-Down Database Design Mini-world Requirements E1 R Relation schemas Conceptual

More information

Normalization. Normalization. Normalization. Data Redundancy

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

More information

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms. Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden Robert C. Nickerson ISYS

More information

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24 LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24 1. A database schema is a. the state of the db b. a description of the db using a

More information

Lecture 2 Normalization

Lecture 2 Normalization MIT 533 ระบบฐานข อม ล 2 Lecture 2 Normalization Walailuk University Lecture 2: Normalization 1 Objectives The purpose of normalization The identification of various types of update anomalies The concept

More information

3. Database Design. 3.1. Functional Dependency. 3.1.01. Introduction. 3.1.02. Value in design. 3.1.03. Initial state. 3.1.05. Aims

3. Database Design. 3.1. Functional Dependency. 3.1.01. Introduction. 3.1.02. Value in design. 3.1.03. Initial state. 3.1.05. Aims of 18 05/03/2007 07:37 3. Database Design This is the Database Design course theme. [Complete set of notes PDF 295Kb]. 3.1. Functional Dependency In this lecture we look at... [Section notes PDF 64Kb]

More information

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ: Review Quiz will contain very similar question as below. Some questions may even be repeated. The order of the questions are random and are not in order of

More information

Introduction to Database Systems. Chapter 4 Normal Forms in the Relational Model. Chapter 4 Normal Forms

Introduction to Database Systems. Chapter 4 Normal Forms in the Relational Model. Chapter 4 Normal Forms Introduction to Database Systems Winter term 2013/2014 Melanie Herschel [email protected] Université Paris Sud, LRI 1 Chapter 4 Normal Forms in the Relational Model After completing this chapter,

More information

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an

More information

BCA. Database Management System

BCA. Database Management System BCA IV Sem Database Management System Multiple choice questions 1. A Database Management System (DBMS) is A. Collection of interrelated data B. Collection of programs to access data C. Collection of data

More information

Normalization in OODB Design

Normalization in OODB Design Normalization in OODB Design Byung S. Lee Graduate Programs in Software University of St. Thomas St. Paul, Minnesota [email protected] Abstract When we design an object-oriented database schema, we need

More information

Teaching Database Modeling and Design: Areas of Confusion and Helpful Hints

Teaching Database Modeling and Design: Areas of Confusion and Helpful Hints Journal of Information Technology Education Volume 6, 2007 Teaching Database Modeling and Design: Areas of Confusion and Helpful Hints George C. Philip, Ph. D. College of Business, The University of Wisconsin

More information

Part I: Entity Relationship Diagrams and SQL (40/100 Pt.)

Part I: Entity Relationship Diagrams and SQL (40/100 Pt.) Part I: Entity Relationship Diagrams and SQL (40/100 Pt.) Q.1.1) Translate the following E-R Schema to SQL-DDL tables using the CREATE Table Statement and check constraints, if needed: LatinName EnglishName

More information

The class slides, your notes, and the sample problem that we worked in class may be helpful for reference.

The class slides, your notes, and the sample problem that we worked in class may be helpful for reference. Page 1 of 5 Normalization Lab 12 and Take-home Exam II Objective The goal of this lab is to give you more practice on normalizing a database. You will analyze an existing database to determine the changes

More information

Normal forms and normalization

Normal forms and normalization Normal forms and normalization An example of normalization using normal forms We assume we have an enterprise that buys products from different supplying companies, and we would like to keep track of our

More information

Introduction to normalization. Introduction to normalization

Introduction to normalization. Introduction to normalization Introduction to normalization Lecture 4 Instructor Anna Sidorova Agenda Presentation Review of relational models, in class exersise Introduction to normalization In-class exercises Discussion of HW2 1

More information

Notes from February 11

Notes from February 11 Notes from February 11 Math 130 Course web site: www.courses.fas.harvard.edu/5811 Two lemmas Before proving the theorem which was stated at the end of class on February 8, we begin with two lemmas. The

More information

Database Sample Examination

Database Sample Examination Part 1: SQL Database Sample Examination (Spring 2007) Question 1: Draw a simple ER diagram that results in a primary key/foreign key constraint to be created between the tables: CREATE TABLE Salespersons

More information

Normalisation 6 TABLE OF CONTENTS LEARNING OUTCOMES

Normalisation 6 TABLE OF CONTENTS LEARNING OUTCOMES Topic Normalisation 6 LEARNING OUTCOMES When you have completed this Topic you should be able to: 1. Discuss importance of the normalisation in the database design. 2. Discuss the problems related to data

More information

DATABASE SYSTEMS. Chapter 7 Normalisation

DATABASE SYSTEMS. Chapter 7 Normalisation DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation 1 (Rob, Coronel & Crockett 978184480731) In this chapter, you will learn: What normalization

More information

DATABASE MANAGEMENT SYSTEMS. Question Bank:

DATABASE MANAGEMENT SYSTEMS. Question Bank: DATABASE MANAGEMENT SYSTEMS Question Bank: UNIT 1 1. Define Database? 2. What is a DBMS? 3. What is the need for database systems? 4. Define tupule? 5. What are the responsibilities of DBA? 6. Define schema?

More information

Introduction to Databases

Introduction to Databases Introduction to Databases IT University of Copenhagen January 7, 2005 This exam consists of 6 problems with a total of 16 questions. The weight of each problem is stated. You have 4 hours to answer all

More information

Chapter 9: Normalization

Chapter 9: Normalization Chapter 9: Normalization Part 1: A Simple Example Part 2: Another Example & The Formal Stuff A Problem: Keeping Track of Invoices (cont d) Suppose we have some invoices that we may or may not want to refer

More information

Normalization. Normalization. First goal: to eliminate redundant data. for example, don t storing the same data in more than one table

Normalization. Normalization. First goal: to eliminate redundant data. for example, don t storing the same data in more than one table Normalization Normalization Purpose Redundancy and Data Anomalies 1FN: First Normal Form 2FN: Second Normal Form 3FN: Thrird Normal Form Examples 1 Normalization Normalization is the process of efficiently

More information

TYPICAL QUESTIONS & ANSWERS

TYPICAL QUESTIONS & ANSWERS TYPICAL QUESTIONS & ANSWERS PART -I OBJECTIVE TYPE QUESTIONS Each Question carries 2 marks. Choosethe correct or the best alternative in the following: Q.1 Which of the following relational algebra operations

More information

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF) DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF) Tables that contain redundant data can suffer from update anomalies, which can introduce inconsistencies into a database. The rules associated

More information