Đang chuẩn bị liên kết để tải về tài liệu:
PATTERNS OF DATA MODELING- P14
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
PATTERNS OF DATA MODELING- P14: 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. | 46 Chapter 3 Directed Graph Template DG Figure 3.19 Node and edge directed graph IDEF1X template. 3.3.3 SQL Queries Figure 3.20 Figure 3.21 and Figure 3.22 show SQL queries for common traversals of the template. The colon prefix denotes variable values that must be provided for each query. SELECT E.edgeID E.edgeName FROM Edge AS E INNER JOIN Node AS Source ON E.sourceNodeID Source.nodeID WHERE Source.nodeID aSourceNodeID ORDER BY E.edgeName Figure 3.20 Node and edge directed graph SQL query. Find the edges that originate from a node. SELECT E.edgeID E.edgeName FROM Edge AS E INNER JOIN Node AS Sink ON E.sinkNodeID Sink.nodeID WHERE Sink.nodeID aSinkNodeID ORDER BY E.edgeName Figure 3.21 Node and edge directed graph SQL query. Find the edges that terminate at a node. SELECT Src.nodeID AS srcNodeID Src.nodeName AS srcNodeName Sink.nodeID AS sinkNodeID Sink.nodeName AS sinkNodeName FROM Edge AS E INNER JOIN Node AS Src ON E.sourceNodeID Src.nodeID INNER JOIN Node AS Sink ON E.sinkNodeID Sink.nodeID WHERE E.edgeID anEdgeID Figure 3.22 Node and edge directed graph SQL query. Find the source and sink nodes for an edge. 3.3 Node and Edge Directed Graph Template 47 3.3.4 Sample Populated Tables Figure 3.23 and Figure 3.24 show node and edge directed graph tables populated with data. The values of the IDs are arbitrary but internally consistent. Node table node ID dgID node Name 1 1 A 2 1 B 3 1 C 4 1 D 5 1 E 6 1 F Edge table edgeID dgID edgeName sourceNodeID sinkNodelD 51 1 c 1 3 52 1 d 1 4 53 1 e 1 5 54 1 f 2 5 55 1 g 3 6 56 1 h 4 6 57 1 i 5 6 Figure 3.23 Node and edge directed graph Populated tables. Node table node ID dgID node Name 11 2 X 12 2 Y edgeID dgID edgeName sourceNodeID sinkNodeID 61 2 r 11 12 62 2 s 11 12 63 2 t 11 11 Figure 3.24 Node and edge directed graph Populated tables. 48 Chapter 3 Directed Graph Template 3.3.5 Examples The node and edge directed graph is the most common representation. Figure 3.25 shows an example for published flights. Figure 3.25 .