Presentation is loading. Please wait.

Presentation is loading. Please wait.

DASWIS 2001 1 NF-SS: A Normal Form for Semistructured Schemata Xiaoying Wu, Tok Wang Ling, Sin Yeung Lee, Mong Li Lee National University of Singapore.

Similar presentations


Presentation on theme: "DASWIS 2001 1 NF-SS: A Normal Form for Semistructured Schemata Xiaoying Wu, Tok Wang Ling, Sin Yeung Lee, Mong Li Lee National University of Singapore."— Presentation transcript:

1 DASWIS 2001 1 NF-SS: A Normal Form for Semistructured Schemata Xiaoying Wu, Tok Wang Ling, Sin Yeung Lee, Mong Li Lee National University of Singapore Gillian Dobbie University of Auckland, New Zealand

2 DASWIS 2001 2 Outline 1. Motivations 2. Semistructured schema and its data tree 3. Integrity constraints for semistructured data 4. NF-SS: Normal Form for Semistructured Schemata 5. Designing of semistructured schema into NF-SS 6. Discussions of the designing approach 7. Comparison with related proposal 8. Summary

3 DASWIS 2001 3 1. Motivation: Example 1 <!ELEMENT department (course+) <!ATTLIST department name ID #REQUIRED> <!ATTLIST course cid ID #REQUIRED title CDATA #implied> <!ATTLIST student sid ID #REQUIRED name CDATA #REQUIRED age CDATA #IMPLIED> course title student sid age name + department grade cid * ? name

4 DASWIS 2001 4 1. Motivation ( cont. ) 4 Redundancy: name and age of a student 4 Updating Anomaly: –Insertion –Rewriting –Deletion

5 DASWIS 2001 5 1. Motivation:Example 2 name CDATA #REQUIRED> <!ATTLIST subject cid ID #REQUIRED> <!ATTLIST day CDATA #REQUIRED hour CDATA #REQUIRED> 4 Path anomaly: –The schema doesn’t reflect the integrity constraints: tid,day,hour  cid,room#

6 DASWIS 2001 6 2. Semistructured Schema and Data tree A semistructured schema is defined to be D = (E, A, B, P, R, r) course title student sid age name + department grade cid * ? name E: Object type A: attribute s E is a finite set of object types in D. A is a finite set of attributes, disjoint from E. P is a function from E to object type definition with symbol in {*, +, ?,1} called multiplicity e.g: P (course) = student * r: root Object type R is a function from E to the power set of A e.g.: R(student) = {sid, name, age } multiplicity r  E and is called the object type of the root. e.g.: r = department B is a set of basic domain type like string, integer, Boolean etc.

7 DASWIS 2001 7 2. Semistructured Schema and Data tree (Cont.) cid: cs4221 title: database design sid: s01 “A” title: data Mining age: 21 name: Jack       course name: CS department course student sid: s02 name: Tom student grade cid: cs5220 sid: s01 age: 21 name: Jack student A data tree T with respect to a semistructured schema D = (E, A, B, P, R, r) is defined to be a tree T=(V, lab, obj, att, val, root), showing a database instance.

8 DASWIS 2001 8 course title student sid age name + department grade cid * ? name The path of a node n in semistructured schema D is denoted as path D (n). e.g.: Path D for student is /department / course / student The path of a node v in data tree T is denoted as Path T (v) e.g.: Path T for student “s02” is /department / course/ student The target set of node n in T, T[n], is {v: v  V, n  E  A Path T (v)= Path D (n)}. e.g.: the target set T[student] includes nodes of students with sid “s02” etc. 2. Semistructured Schema and Data tree (Cont.)

9 DASWIS 2001 9 2. Semistructured Schema and Data tree (Cont.) 4 Two nodes from two data tree w.r.t schema D satisfy value equality iff –they are attributes nodes with the same tag and the same value; –or they are object nodes having the same tag and their children are pairwise value equal cid: cs4221 title: database design sid: s01 “A” title: data Mining age: 21 name: Jack      course name: CS department course sid: s02 name: Tom student grade cid: cs5220 sid: s01 age: 21 name: Jack student  Two data trees T 1 and T 2 w.r.t schema D = (E, A, B, P, R, r), X  E  A. T 1 and T 2 agree on X, denoted as iff the following condition is hold:  t 1  T 1 [X],t 2  T 2 [X], such that (t 1 = v t 2 )

10 DASWIS 2001 10 3. Integrity Constraints for Semistructured Data 4 Extended Functional Dependency(EFD) Let D = (E, A, B, P, R, r) be a semistructured schema, let X  E  A and Y  E  A. Y is extended functionally dependent on X, is denoted as X  Y. Let S denotes a set of data trees that are images of D, S satisfies X  Y, iff for any data trees T 1, T 2 in S, if they agree on every component in X, then they will agree on Y.that is,  T 1, T 2  S((  x  X, T 1 = x T 2 ) such that T 1 = y T 2 ). 4 Inference rule for EFD E1:(reflexivity) If Y  X, then X  Y, for any X, Y  E  A E2:(augmentation) if X  Y then XZ  YZ, for any X, Y, Z  E  A E3:(transitivity) If X  Y, Y  Z then X  Z, for any X, Y, Z  E  A

11 DASWIS 2001 11 3. Integrity Constraints for Semistructured Data (Cont.) 4 Notation: 4 EFD X  Y is partial EFD: If there exists an X’  X such that X’  Y. Otherwise, is full EFD. e.g.: (1) course[@cid],student[@sid]  student[@name] is partial EFD (2) student[@sid]  student[@name] its full EFD 4 X  Y is said to be coherent iff /X/Y is a path in D; otherwise it is called an incoherent EFD. O 1 [@X 1 ], …, O i [@X i ],…,O n-1 [@X n-1 ]  O n [@X n ] e.g.:teacher[@tid], time [@day, @hour]  subject[@cid] is an incoherent EFD, since /teacher / time /subject is not a path in schema.

12 DASWIS 2001 12 3. Integrity Constraints for Semistructured Data (Cont.) 4 If there exists Z  E  A, such that X  Y and Y  Z and Y X, then Z is transitively extended functionally dependent on X via Z. e.g.: age is transitively dependent on course via student since (1) course[@cid]  student[@sid] (2) student[@sid]  student[@age] and (3)student[@sid] course[@cid] course title student sid age name + department grade cid * ? name

13 DASWIS 2001 13 3. Integrity Constraints for Semistructured Data (Cont.) 4Theorem Let D = (E, A, B, P, R, r) be a semistructured schema, X, Y, Z  E  A. If Z is transitively dependent on X via Y, then there exists a data tree of D where a rewriting anomaly occurs upon updating the values of Z.

14 DASWIS 2001 14 3. Integrity Constraints for Semistructured Data (Cont.) 4 Key Constraints : Based on EFD semantics 4 Notation: K o = O 1 [@X 1 ]/…/O i [@X i ]/…/O n [@X n ]/O[@X] for key of an object type O in semistructured schema D. /O 1 /…/O is a path in D If n equals one, then K o is called an absolute key. Otherwise it is called a relative key. Example K book = book[@isbn]. K book is an absolute key K chapter =book[@isbn]/chapter[@number]. K chapter is a relative key K section = book[@isbn]/chapter[@number]/section[@number]. K section is a relative key

15 DASWIS 2001 15 3. Integrity Constraints for Semistructured Data (Cont.) Let D be a semistructured schema and O be its root object type. The set of basic dependencies of D, denoted as BD(D), is defined as follows: 4 Let X, Y be children of O, non-trivial extended functional dependencies of the form X  Y where X is a key of O or Y is part of a key of O, are in BD(D).  Let O 1 be a sub-object type of O and D 1 be a schema tree that is rooted at O 1 and add K O as attribute(s) of O 1, then BD(D 1 )  BD(D). 4 No other non-trivial dependencies that is not generated from above is in BD(D)

16 DASWIS 2001 16 4. NF-SS Let D be a semistructured schema and O be its root object type. D is in Normal Form for Semistructured Schemata (NF-SS), iff 1.O has at least one key. 2. For any non-trivial EFD of the form X  Y satisfied by O, where X and Y are attributes of O, then either X is a key or Y is part of the key of O 3.For any sub-object type O 1 of O (a) If adding K O to O 1 as its components with other remains, a schema tree rooted at O 1 will be in NF-SS. (b) K O  K O1 =  or K O  K O1, where K O and K O1 are O and O 1 ’ s key respectively. (c) O 1 is not transitively dependent on K O 4. Any non-trivial EFD in D can be derived from BD(D) by using the inference rules for EFDs.

17 DASWIS 2001 17 5. Designing Semistructured Schema into NF-SS 4 We adopt restructuring approach for the designing. 4 We propose four heuristic restructuring rules –Decomposition object types. –Creation new object types. –Regrouping components of an object type. 4 Objective –Remove transitive or partial EFD and incoherent EFD from the given dependency and key constraints.

18 DASWIS 2001 18 5. Designing Semistructured Schema into NF-SS (cont.) Rule 1. (Remove Transitive Dependency by Decomposition) Given an object type O in a semistructured schema D, if there is some non-prime component(s) Y of O that is transitively dependent on some key of O, i.e., K O  X, X  Y and X K O, and X  K O = . Then, restructuring the schema as follows. 1. Duplicate X to form a new node(s) Z. 2. Move Y and all the descendants of Y and their corresponding edges under Z. 3. Make X as foreign key of O, and add a reference edge from the original node X to Z.

19 DASWIS 2001 19 5. Designing Semistructured Schema into NF-SS (cont.) 4 Example 5.1: schema D satisfies the following EFDs (1)department[@name]  course[@cid] (2) course[@cid]  department (3)course[@cid]  course[@title] (4)course[@cid]  student[@sid (5)course[@cid],student[@sid]  grade (6)student[@sid]  student[@name, @age]

20 DASWIS 2001 20 5. Designing Semistructured Schema into NF-SS (cont.) Rule 2. Remove Path Anomaly by Path Splitting Given a semistructured schema D. Suppose there exists an incoherent EFD: O 1 [@X 1 ],…,O n [@X n ]  Y, Y is either an object type or an attribute, and there exists a path P that contains {O 1,…,O n,Y}. Path P can be split into two sub-paths P 1 and P 2,where P 1 only contains {O 1,…,O n } and Y, while P 2 contains {O 1,…,O n } and (P-Y).

21 DASWIS 2001 21 5. Designing Semistructured Schema into NF-SS (cont.) 4 Example 5.2:schema D satisfies following EFDs (1) teacher[@tid],time  ClassRoom (2)teacher[@tid], time  subject

22 DASWIS 2001 22 5. Designing Semistructured Schema into NF-SS (cont.) Rule 3. Removing Partial Dependency by Creating New Object type Given an object type O in a semistructured schema, let X be a set of prime attributes of O, and Y be the set of O ’ s attributes. Let O 1 be a sub-object type of O. If (K O -X)  O 1 and no proper superset of X satisfy this property, then restructure the schema as follows: 1. (K O  Y – X) becomes the only attribute(s) of O while O 1 remains to be its sub-object type. 2.Create a new object type O 2 that is a direct component of O. 3.Move rest of the components of O and all their descendants and corresponding edges under O 2.

23 DASWIS 2001 23 5. Designing Semistructured Schema into NF-SS (cont.) 4 Example 5.3: schema D shown in Figure (a). the following EFDs {O[@A,@B]  D, O[@A,@B]  O 2, O[@A]  O 1, O[@A]  E } and the key of O is {A,B}.

24 DASWIS 2001 24 5. Designing Semistructured Schema into NF-SS (cont.) Rule 4. (Restructuring To Satisfy Condition 3(b) of NF-SS Definition) Given an object type O in a semistructured schema D, X be a set of O ’ s attributes and single-valued atomic sub-object types, O 1 be a complex sub-object type of O. O 1 has relative key K O1, but K O  K O1 and K O1 K O. Let Y be K O  K O1  X, and Y . D is restructured as follows: 1. O 1 remains to be a sub-object type of O. 2. Make Y as components of O. 3.Create a new object type O 2 to be a child of O and the rest components of O (excluding Y) become children of O 2.

25 DASWIS 2001 25 5. Designing Semistructured Schema into NF-SS (cont.)  Example 5.4: schema D in Figure (a) satisfies the EFD (1) O[@K, @A]  O 1 (2) O[@K, @B]  O 2 and the key of O is {K, A, B}.

26 DASWIS 2001 26 5. Designing Semistructured Schema into NF-SS (cont.) Algorithm 1: Restructuring Algorithm Input: A set S that contains semistructured schemas, and a set of EFDs for S. Output: A set of semistructured schemas that in NF-SS. Begin 1. for each semistructured schema D in S do if D is not in NF-SS then repeat until no further change: (1) if there exists transitive EFD: K O  X, X  Y and X K O for an object type O in D, Case X  K O =  : apply Rule 1 to remove the transitive EFD. Case X  K O : apply Rule 3 to remove the transitive EFD. Case X  K O  : apply Rule 4 to remove the transitive EFD. (2) if there exists incoherent EFD then apply Rule 2 to remove it. 2. output S. End

27 DASWIS 2001 27 6. Discussion of Restructuring Approach for Designing 4 Is the restructuring rules complete? No. –covering is not guaranteed –dependency preservation is not guaranteed 4 Does it give unique solution? No. –depending on the order in which the dependencies are examined 4 Designing task can be made easier if more semantics available. –In [5], We have proposed another approach for designing semistructured databases using ORA-SS, a semantic rich model. 4 Nevertheless, it does give practical heuristics and provides insights into the normalization task for semistructured databases.

28 DASWIS 2001 28 7. Comparison with Related Proposal 4 The first attempt to define normal form for semistructured data ([ER’99] S.Y.Lee, M.L.Lee, T.W.Ling, and L.A.Kalinichenko.) [3] –Defines a schema called S3-Graph, which makes no distinction between element node and attribute node and no cardinality specification. –Proposes S3-NF, but missing key constraints, an essential part of database design. –The decomposition method may not be able to remove some other kinds of anomalies, like partial dependency and path anomaly that may exist in a schema. 4 The most recent proposal: XNF (XML Normal Form) ([ER 2001] D.W.Embley and W.Y.Mok. ) [2] –It mainly provides algorithms to translate a schema, represented in a conceptual model called CM hypergraphs, to a scheme-tree forest in XNF. –Like S3-Graph, scheme tree doesn't lend itself to XML definition. –XNF isn’t formulated with the concept of key. –The algorithms given suffers from efficiency. –A large set of results is expected.

29 DASWIS 2001 29 8. Summary 4 A normal for semistructured schemata –It is incorporated with integrity constraints. –It guarantees no redundancy and hence no undesirable updating anomalies for the conforming semistructured databases. –It gives more reasonable representations of real world semantics 4 Restructuring Approach for designing semistructured databases –a set of heuristic restructuring rules is proposed. –an algorithm for iteratively restructuring a schema into NF-SS is developed. –It provides insights into the normalization task for semistructured databases.

30 DASWIS 2001 30 References 1. J. Clark and S. DeRose. XML Path Language (XPath). W3C Working Darft, November 1999. http://www.w3.org/TR/xpath. 2.D.W.Embley and W.Y.Mok. Developing XML Documents with Guaranteed “Good” Properties. Proceedings of the 20th International Conference on Conceptual Modeling (ER), 2001. 3. S. Y. Lee, M. L. Lee, T. W. Ling and L. A.. Kalinichenko. Designing Good Semi-structured Databases. Proceedings of the 18th International Conference on Conceptual Modeling (ER), 1999. 4. T. W. Ling and L. L. Yan. NF-NR: A Practical Normal Form for Nested Relations. Journal of Systems Integration. Vol4, 1994, pp309-340 5. Xiaoying Wu, Tok Wang Ling, Mong Li Lee, Gillian Dobbie. Designing Semistructured Databases Using the ORA-SS Model, accepted for publication in Proceedings of the 2nd International Conference on Web Information Systems Engineering (WISE), IEEE Computer Society, Kyoto, Japan, December 2001.

31 DASWIS 2001 31 Q&A


Download ppt "DASWIS 2001 1 NF-SS: A Normal Form for Semistructured Schemata Xiaoying Wu, Tok Wang Ling, Sin Yeung Lee, Mong Li Lee National University of Singapore."

Similar presentations


Ads by Google