Introduction |
|
xiii | |
|
1 Graphs, Trees, and Hierarchies |
|
|
1 | (10) |
|
1.1 Defining Tree and Hierarchies |
|
|
3 | (3) |
|
|
3 | (1) |
|
1.1.2 Properties of Hierarchies |
|
|
4 | (1) |
|
1.1.3 Types of Hierarchies |
|
|
5 | (1) |
|
|
6 | (1) |
|
1.3 Modeling a Graph in a Program |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (3) |
|
|
11 | (24) |
|
2.1 The Simple Adjacency List Model |
|
|
12 | (1) |
|
2.2 The Simple Adjacency List Model Is Not Normalized |
|
|
13 | (4) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
2.2.4 Structural Anomalies |
|
|
16 | (1) |
|
2.3 Fixing the Adjacency List Model |
|
|
17 | (4) |
|
2.3.1 Concerning the Use of NULLs |
|
|
20 | (1) |
|
2.4 Navigation in Adjacency List Model |
|
|
21 | (6) |
|
2.4.1 Cursors and Procedural Code |
|
|
21 | (1) |
|
|
21 | (2) |
|
2.4.3 Finding a Subtree with Recursive CTE |
|
|
23 | (1) |
|
2.4.4 Finding a Subtree with Iterations |
|
|
24 | (1) |
|
|
25 | (2) |
|
2.5 Inserting Nodes in the Adjacency List Model |
|
|
27 | (1) |
|
2.6 Deleting Nodes in the Adjacency List Model |
|
|
27 | (3) |
|
2.6.1 Deleting an Entire Subtree |
|
|
27 | (1) |
|
2.6.2 Promoting a Subordinate after Deletion |
|
|
28 | (1) |
|
2.6.3 Promoting an Entire Subtree after Deletion |
|
|
29 | (1) |
|
2.7 Leveled Adjacency List Model |
|
|
30 | (5) |
|
|
31 | (1) |
|
2.7.2 Aggregation in the Hierarchy |
|
|
31 | (4) |
|
3 Path Enumeration Models |
|
|
35 | (14) |
|
3.1 Finding the Depth of the Tree |
|
|
37 | (1) |
|
3.2 Searching for Subordinates |
|
|
37 | (2) |
|
3.3 Searching for Superiors |
|
|
39 | (1) |
|
|
39 | (1) |
|
3.5 Deleting a Single Node |
|
|
39 | (1) |
|
|
40 | (1) |
|
3.7 Splitting up a Path String |
|
|
40 | (2) |
|
3.8 Microsoft SQL Server's HIERARCHYID |
|
|
42 | (2) |
|
3.9 Edge Enumeration Model |
|
|
44 | (1) |
|
|
45 | (4) |
|
4 Nested Sets Model of Hierarchies |
|
|
49 | (62) |
|
4.1 Finding Root and Leaf Nodes |
|
|
51 | (2) |
|
|
53 | (1) |
|
4.3 Finding Levels and Paths in a Tree |
|
|
54 | (9) |
|
4.3.1 Finding the Height of a Tree |
|
|
54 | (1) |
|
4.3.2 Finding Levels of Subordinates |
|
|
55 | (5) |
|
4.3.3 Finding Oldest and Youngest Subordinates |
|
|
60 | (2) |
|
|
62 | (1) |
|
4.3.5 Finding Relative Position |
|
|
63 | (1) |
|
4.4 Functions in the Nested Sets Model |
|
|
63 | (1) |
|
4.5 Deleting Nodes and Subtrees |
|
|
64 | (7) |
|
|
65 | (3) |
|
4.5.2 Deleting a Single Node |
|
|
68 | (3) |
|
4.5.3 Pruning a Set of Nodes from a Tree |
|
|
71 | (1) |
|
4.6 Closing Gaps in the Tree |
|
|
71 | (3) |
|
4.7 Summary Functions on Trees |
|
|
74 | (9) |
|
4.7.1 Iterative Parts Update |
|
|
75 | (5) |
|
4.7.2 Recursive Parts Update |
|
|
80 | (3) |
|
4.8 Inserting and Updating Trees |
|
|
83 | (14) |
|
4.8.1 Moving a Subtree within a Tree |
|
|
85 | (4) |
|
4.8.2 MoveSubtree Second Version |
|
|
89 | (2) |
|
4.8.3 Insertion of an Immediate Subtree |
|
|
91 | (2) |
|
4.8.4 Subtree Duplication |
|
|
93 | (3) |
|
|
96 | (1) |
|
4.9 Converting Nested Sets Model to Adjacency List Model |
|
|
97 | (1) |
|
4.10 Converting Adjacency List Model to Nested Sets Model |
|
|
98 | (4) |
|
|
98 | (2) |
|
4.10.2 Ben-Gan's Recursive Common Table Expression (CTE) |
|
|
100 | (2) |
|
4.11 Separation of Edges and Nodes |
|
|
102 | (2) |
|
4.11.1 Multiple Structures |
|
|
103 | (1) |
|
|
103 | (1) |
|
4.12 Comparing Nodes and Structure |
|
|
104 | (4) |
|
4.13 Nested Sets Code in Other Languages |
|
|
108 | (3) |
|
5 Frequent Insertion Trees |
|
|
111 | (38) |
|
5.1 The Data Type of (lft, rgt) |
|
|
113 | (2) |
|
5.1.1 Exploiting the Full Range of Integers |
|
|
113 | (1) |
|
5.1.2 FLOAT, REAL, or Double Precision Numbers |
|
|
114 | (1) |
|
5.1.3 NUMERIC(p, s) or DECIMAL(p, s) Numbers |
|
|
114 | (1) |
|
5.2 Computing the Spread to Use |
|
|
115 | (9) |
|
|
118 | (1) |
|
|
118 | (1) |
|
5.2.3 Divisor via Formula |
|
|
119 | (1) |
|
5.2.4 Divisor via Table Lookup |
|
|
119 | (1) |
|
5.2.5 Partial Reorganization |
|
|
120 | (2) |
|
5.2.6 Rightward Spread Growth |
|
|
122 | (2) |
|
|
124 | (6) |
|
5.3.1 Reorganization with Lookup Table |
|
|
124 | (5) |
|
5.3.2 Reorganization with Recursion |
|
|
129 | (1) |
|
5.4 Rational Numbers and Nested Intervals Model |
|
|
130 | (17) |
|
5.4.1 Partial Order Mappings |
|
|
132 | (3) |
|
5.4.2 Summation of Coordinates |
|
|
135 | (3) |
|
5.4.3 Finding Parent Encoding and Sibling Number |
|
|
138 | (2) |
|
5.4.4 Calculating the Enumerated Path and Distance between Nodes |
|
|
140 | (4) |
|
5.4.5 Building a Hierarchy |
|
|
144 | (1) |
|
5.4.6 Depth-first Enumeration by Left Interval Boundary |
|
|
145 | (1) |
|
5.4.7 Depth-first Enumeration by Right Interval boundary |
|
|
145 | (1) |
|
5.4.8 All Descendants of a Node |
|
|
146 | (1) |
|
|
147 | (2) |
|
6 Linear Version of the Nested Sets Model |
|
|
149 | (8) |
|
6.1 Insertion and Deletion |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
153 | (1) |
|
6.4 Cash Register Tape Problem |
|
|
153 | (4) |
|
|
157 | (16) |
|
7.1 Binary Tree Traversals |
|
|
159 | (2) |
|
|
161 | (3) |
|
7.2.1 Find Parent of a Node |
|
|
162 | (1) |
|
7.2.2 Find Subtree at a Node---Recursive Common Table Expression (CTE) |
|
|
163 | (1) |
|
7.2.3 Find Subtree at a Node---Data Driven |
|
|
163 | (1) |
|
7.3 Deletion from a Binary Tree |
|
|
164 | (1) |
|
7.4 Insertion into a Binary Tree |
|
|
165 | (1) |
|
|
165 | (3) |
|
7.6 Binary Tree Representation of Multiway Trees |
|
|
168 | (1) |
|
7.7 Stern--Brocot Numbers |
|
|
169 | (4) |
|
|
173 | (14) |
|
8.1 Adjacency List with Self-References |
|
|
173 | (1) |
|
8.2 Subordinate Adjacency List |
|
|
174 | (1) |
|
|
175 | (5) |
|
8.3.1 Adjacency and Nested Sets Model |
|
|
175 | (1) |
|
8.3.2 Nested Sets with Depth Model |
|
|
176 | (1) |
|
8.3.3 Adjacency and Depth Model |
|
|
177 | (1) |
|
8.3.4 Computed Hybrid Models |
|
|
178 | (2) |
|
8.4 Path Enumeration Using Prime Number Products |
|
|
180 | (7) |
|
8.4.1 Find the Subordinates of a Node |
|
|
181 | (1) |
|
8.4.2 Find the Superiors of a Node |
|
|
181 | (1) |
|
8.4.3 Hierarchy with Levels |
|
|
182 | (1) |
|
8.4.4 Insert New Employee under a Boss |
|
|
182 | (1) |
|
|
183 | (1) |
|
|
184 | (1) |
|
|
184 | (3) |
|
9 Proprietary Extensions for Trees |
|
|
187 | (8) |
|
9.1 Oracle Tree Extensions |
|
|
187 | (3) |
|
9.1.1 Related Tree Extensions |
|
|
190 | (1) |
|
9.2 DB2 and the WITH Operator |
|
|
190 | (1) |
|
9.3 Date's EXPLODE Operator |
|
|
191 | (1) |
|
9.4 Tillquist and Kuo's Proposals |
|
|
192 | (1) |
|
|
192 | (1) |
|
|
193 | (2) |
|
10 Hierarchies in Data Modeling |
|
|
195 | (16) |
|
10.1 Types of Hierarchies |
|
|
200 | (1) |
|
10.2 Data Definition Language Constraints |
|
|
200 | (11) |
|
10.2.1 Uniqueness Constraints |
|
|
201 | (3) |
|
10.2.2 Disjoint Hierarchies |
|
|
204 | (3) |
|
10.2.3 Representing l:l, l:m, and n:m Relationships |
|
|
207 | (4) |
|
11 Hierarchical Encoding Schemes |
|
|
211 | (8) |
|
|
211 | (1) |
|
11.2 Dewey Decimal Classification |
|
|
212 | (1) |
|
11.3 Strength and Weaknesses |
|
|
213 | (2) |
|
|
215 | (2) |
|
11.5 Statistical Tools for Decision Trees |
|
|
217 | (2) |
|
|
219 | (20) |
|
12.1 Adjacency List Model Graphs |
|
|
219 | (12) |
|
12.1.1 SQL and the Adjacency List Model |
|
|
220 | (2) |
|
|
222 | (5) |
|
|
227 | (2) |
|
12.1.4 Adjacency Matrix Model |
|
|
229 | (2) |
|
12.2 Split Node Nested Sets Models for Graphs |
|
|
231 | (8) |
|
12.2.1 All Nodes in the Graph |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (1) |
|
|
233 | (1) |
|
12.2.5 Indegree and Outdegree |
|
|
234 | (1) |
|
12.2.6 Source, Sink, Isolated, and Internal Nodes |
|
|
235 | (1) |
|
12.2.7 Converting Acyclic Graphs to Nested Sets |
|
|
236 | (3) |
|
|
239 | (8) |
|
13.1 Data Definition Language for Petri Nets |
|
|
242 | (5) |
|
14 State Transition Graphs |
|
|
247 | (10) |
|
14.1 The Temporal Side of Changes |
|
|
252 | (5) |
|
15 Hierarchical Database Systems (IMS) |
|
|
257 | (16) |
|
|
257 | (1) |
|
|
258 | (4) |
|
|
260 | (1) |
|
|
260 | (1) |
|
15.2.3 Data Communications |
|
|
261 | (1) |
|
15.2.4 Application Programs |
|
|
261 | (1) |
|
15.2.5 Hierarchical Databases |
|
|
261 | (1) |
|
15.2.6 Strengths and Weaknesses |
|
|
262 | (1) |
|
15.3 Sample Hierarchical Database |
|
|
262 | (9) |
|
15.3.1 Department Database |
|
|
264 | (1) |
|
|
264 | (1) |
|
15.3.3 Design Considerations |
|
|
265 | (1) |
|
15.3.4 Example Database Expanded |
|
|
265 | (1) |
|
15.3.5 Data Relationships |
|
|
266 | (2) |
|
15.3.6 Hierarchical Sequence |
|
|
268 | (1) |
|
15.3.7 Hierarchical Data Paths |
|
|
268 | (1) |
|
|
269 | (1) |
|
|
270 | (1) |
|
15.3.10 Segment Definitions |
|
|
271 | (1) |
|
|
271 | (2) |
Index |
|
273 | |