Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
PATTERNS OF DATA MODELING- P11: Models provide the means for building quality software in a predictable manner. Models let developers think deeply about software and cope with large size and complexity. Developers can think abstractly before becoming enmeshed in the details of writing code. Although models are beneficial, they can be difficult to construct. That is where patterns come in. Patterns provide building blocks that help developers construct models faster and better. | 2.6 Degenerate Node and Edge Template 31 2.6 Degenerate Node and Edge Template 2.6.1 UML Template The degenerate node and edge template Figure 2.40 is useful when there is a need to store data about the parent-child grouping. I call it degenerate node and edge because it is based on the node and edge directed graph template presented in the next chapter. This template rarely occurs. 0.11 root parent Node 0.1 1 0.1 Entity child cannot be any cycles. Tree There Figure 2.40 Degenerate node and edge UML template. Use when you need to store data about the parent-child coupling. A Tree is a hierarchy of entities and has one entity as the root. A Node is a position within a Tree and groups one parent Entity with all of its child Entities. An Entity is something with identity and data. The sequencing of the Nodes of a Tree occurs via the couplings to Entities. You need not show Tree in a use of the template. In this template Nodes have globally unique names as there is no context for defining the scope of uniqueness. 2.6.2 IDEF1X Template Figure 2.41 restates Figure 2.40 with the IDEF1X notation. The following are foreign keys rootID references Node nodelD references Node and parentID references Entity. Tree Node Entity Figure 2.41 Degenerate node and edge IDEF1X template. 2.6.3 SQL Queries Figure 2.42 and Figure 2.43 show SQL queries for common traversals of the template. The colon prefix denotes variable values that must be provided for each query. 32 Chapter 2 Tree Template SELECT Parent.entityID AS parentEntityID Parent.entityName AS parentEntityName FROM Entity AS Child INNER JOIN Node AS N ON Child.nodeID N.nodeID INNER JOIN Entity AS Parent ON N.parentID Parent.entityID WHERE Child.entityID aChildEntityID Figure 2.42 Degenerate node and edge SQL query. Find the parent for a child node. SELECT Child.entityID AS childEntityID Child.entityName AS childEntityName FROM Entity AS Child INNER JOIN Node AS N ON Child.nodeID N.nodeID INNER JOIN Entity AS Parent ON .