330 likes | 471 Views
COMP 630E Group Project. An Illustration of Data Dependencies. Group 2. Ko Wai Sun, Eric Leung Cheuk Yung, Victor Ng Ching Yu, Cedric Wong Yee Man, Shirley. Outline. The Example Functional Dependency (FD) Inclusion Dependency (IND) Multivalued Dependency (MVD)
E N D
COMP 630E Group Project An Illustration of Data Dependencies Group 2 Ko Wai Sun, Eric Leung Cheuk Yung, Victor Ng Ching Yu, Cedric Wong Yee Man, Shirley
Outline • The Example • Functional Dependency (FD) • Inclusion Dependency (IND) • Multivalued Dependency (MVD) • Join Dependency (JD)
Example Database • Consider the following example • A database is designed to record the information about students, professors and courses taken in a semester. • Click to view the schema and relations of the database.
Data Dependency • Data dependency (DD) is a part of integrity constrains that forms the basis of relation data model and is used to express the semantics of the database. • In this project, we have three main categories of DD • Functional Dependency (FD) • Inclusion Dependency (IND) • Multivalued Dependency (MVD) & Join Dependency (JD)
Functional Dependency (FD) • FD imposes restrictions within a single schema. • It restricts the data in the database follows certain kind of rules. • Armstrong’s Relations generalize six important rules in describing the FD in schema
Functional Dependency (FD) • Consider thestudentrelation
Functional Dependency (FD) • Reflexivity • If Y X schema(R) then we have F├XY. • Example • sname sfullname => F ├ sfullname sname • each student’s name (sname) is a subset of his/her full name (sfullname). Hence we can determine the student’s name from his/her full name.
Functional Dependency (FD) • Augmentation • If F├XY and W is a (set of) attribute(s) in the schema, then F├XWYW • Example • F ├ sid sprogram => F ├ {sid, sdept} {sprogram, sdept} • A student’s student ID (sid) can determine his/her program of study (sprogram). • Then the student’s ID together with his/her belonging department can determine the program he/she is studying together with the department he/she belongs to.
Functional Dependency (FD) • Transitivity • If F├XY and F├YZ, then F├XZ. • Example • F├ sid sprogram and F├ sprogram sdeptthen F├ sid sdept • Student identity number (sid) determines the program (sprogram) he/she has registered, and each program must refer to a department (sdept). We can find the department that the student belongs to by the student identity number.
Functional Dependency (FD) • Union • If F├XY and F├XZ, then F├XYZ. • Example • F├ sid sname and F├ sid sprogramthen F├ sid {sname, sprogram} • Student ID (sid) determines the name of the student (sname), it also determines the program the student has registered (sprogram). • Thus if we know the student ID, we can altogether know the student name and the program of that student.
Functional Dependency (FD) • Decomposition • If F├XYZ, then F├XY and F├XZ. • Example • F├ sid {sprogram, sdept}then F├ sid sprogram and F├ sid sdept. • Student ID (sid) determines the program registered (sprogram) and the department he/she belongs to (sdept). • With this student ID, we can find the program he/she has registered and the department he/she belongs to separately.
Functional Dependency (FD) • Pseudo-transitivity • If F├XY and F├YWZ, then F├XWZ. • Example • If F├ sid sname and F├ {sname, sprogram} sdept , then F├ {sid, sprogram} sdept • Student ID (sid) determines the student name (sname). Knowing the student name and the program that he/she has registered (sprogram), we can know the department he/she belongs to (sdept). • Then, if we know the student ID of the student and the the registered program, we can know the department this student belongs to.
Inclusion Dependency (IND) • IND is the rule among different schemas • Consider the student and department relations student department
Inclusion Dependency (IND) • In the student relation, we only have the student ID of the student and his/her corresponding department ID number. • Normally every student must belong to a department. • There should not exist that the relation contains a department with an unknown department identity number, or that the department has no identity number.
Inclusion Dependency (IND) • Just the same as FD, there is a tool to formulate the IND between schemas • This tool is called “Casanova et al.’s axiom system” • We consider the following three rules: • Reflexivity • Projection and Permutation • Transitivity
Inclusion Dependency (IND) • Reflexivity • If X is (are) attribute(s) in a schema R, we have IND├ R[X] R[X]. • Example • In student relation, IND ├ student[sid] student[sid] • It gives the basis of inclusion dependency.
Inclusion Dependency (IND) • Projection and permutation • If IND├R1[X]R2[Y], then IND├R1[Xk]R2[Yk] where Xk and Yk are projection and permutation on X and Y • Example • In the teach relation, course ID and the course description are subset of records in the course relation. If we use course ID as referential key to the course relation, there must exist some records in course relation for the same description as the course description.
Inclusion Dependency (IND) teach course teach[{course, cdescription}] course[{course, cdescription, credit}]=> teach[cdescription] course[cdescription]
Inclusion Dependency (IND) • Transitivity • If IND├R1[X]R2[Y] and IND├R2[Y]R3[Z], then IND├R1[X]R3[Z] • Example • In the pattern relation, it records what courses a student needs to take and only the course ID is known. It is trivial that the course ID is a subset of the course ID in the teach relation. As course ID in the teach relation is also a subset of that in the course relation, from the pattern relation, we can use the course ID as referential key to the course relation.
Inclusion Dependency (IND) If IND├ pattern[course] teach[course] pattern teach
Inclusion Dependency (IND) and IND├ teach[course] course[course] teach course
Inclusion Dependency (IND) then IND├ pattern[course] course[course] pattern course
Multivalued Dependency (MVD) & Join Dependency (JD) • The third type of DD is related to the decomposition restriction on a single schema. • This includes multivalued dependency (MVD) and join dependency (JD)
Multivalued Dependency (MVD) • Notation: MVD ├ A B • Example • In the relation pattern. An MVD deptcourse is satisfied. • t1 [dept] = t2 [dept] = t3 [dept] = t4 [dept] = 1 • t3 [course] = t1 [course] = COMP104 • t4 [course] = t2[course] = COMP171 • Also, t5 [dept] = t6 [dept] = t7 [dept] = t8 [dept] = 2 • t7 [course] = t5 [course] = ELEC102 • t8 [course] = t6 [course] = ELEC151
Multivalued Dependency (MVD) student requirement
Multivalued Dependency (MVD) pattern Two students in the same department take the same courses
Multivalued Dependency (MVD) • Example (cont’d) • In other words, students in the same department follow the same study pattern to take courses. • Students (1001, 1002) in the Computer Sci. department take COMP104 and COMP171 • and those (1003, 1004) in the Electronic Eng. department take ELEC102 and ELEC151. • Example
Join Dependency (JD) • JD is the general version of MVD • If the schema can be broken up into n (n≥1) or more schema losslessly, the schema obeys JD. • particularly, when n=1, it is the trivial case. • when n=2, it is actually MVD.
Join Dependency (JD) • Example • In the relation enrollment • JD ((student, course), (course, lecturer), (student, lecturer)) holds, • but JD ((student,course), (course,lecturer)) does not. enrollment
Join Dependency (JD) • Decompose the relation enrollment into 3 relations as follows
Join Dependency (JD) • When the three relations are joined back together, it will be the same as before decomposing. • But joining the first two relations ((student, course), (course, lecturer)) would generate some spurious results. • The natural join is as shown in the next slide
Join Dependency (JD) The tuples with red values are spurious. They do not exist in the original enrollment relation. Therefore the JD of joining these two relations does not hold.