1. Trang chủ
  2. » Công Nghệ Thông Tin

PATTERNS OF DATA MODELING- P18 pptx

5 208 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 152,9 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

4.2 Connection Undirected Graph Template 4.2.1 UML Template Figure 4.8 elaborates the node and edge template, promoting the connection between nodes and edges to an entity type.. A Node

Trang 1

66 Chapter 4 / Undirected Graph Template

Figure 4.7 shows a model for the LinkedIn network using the node and edge undirected graph template The LinkedIn Web site manages extensive data about members that Figure 4.7 does not show as the emphasis is on the template

4.2 Connection Undirected Graph Template

4.2.1 UML Template

Figure 4.8 elaborates the node and edge template, promoting the connection between nodes

and edges to an entity type Figure 4.8, as stated, does not permit unconnected Nodes You could add a relationship between UDG and Node if unconnected Nodes were important.

A UDG (undirected graph) is a set of nodes and a set of edges that connect nodes You need not show UDG in a use of the template A Node is an entity type whose records are

Figure 4.6 Node and edge undirected graph: Populated tables

B c

d

e

F

A

f

g

Node table

node

ID

node

Name

udg ID

Edge table

edge ID

edge Name

udg ID

Node_Edge table

node ID

edge ID

1 51

3 51

1 52

4 52

1 53

5 53

2 54

Node_Edge table (cont)

node ID

edge ID

5 54

3 55

6 55

4 56

6 56

5 57

6 57

*

2

Figure 4.7 Node and edge undirected graph: Personal networking model

Member

name

Link

emailAddress password

Trang 2

organized as an undirected graph An Edge is a coupling between Nodes A Connection is

the linking between a Node and an Edge.

With this template the names of nodes and edges are globally unique There is no context

to provide an alternative approach to naming

Figure 4.8 lacks the constraint that related nodes and edges must all belong to the same undirected graph

4.2.2 IDEF1X Template

Figure 4.9 restates Figure 4.8 with the IDEF1X notation The following are foreign keys:

udgID references UDG, nodeID references Node, and edgeID references Edge The combi-nation of nodeID + edgeID need not be unique for a Connection as a Node and Edge can

con-nect twice

4.2.3 SQL Queries

Figure 4.10 and Figure 4.11 show SQL queries for common traversals of the template The colon prefix denotes variable values that must be provided for each query

4.2.4 Sample Populated Tables

Figure 4.12 and Figure 4.13 show connection undirected graph tables populated with data The values of the IDs are arbitrary, but internally consistent

<UDG>

<Node> <Edge>

0 1

Figure 4.8 Connection undirected graph: UML template Use when there is

data for the connection itself or edges connect to the same node

*

<Connection>

connectionID

Connection

udgID (FK) nodeID (FK) edgeID (FK)

Figure 4.9 Connection undirected graph: IDEF1X template

nodeID

nodeName (AK1.1)

Node

edgeID edgeName (AK1.1)

Edge

udgID

UDG

Trang 3

68 Chapter 4 / Undirected Graph Template

Figure 4.10 Connection undirected graph: SQL query Find the edges

that connect to a node and how often they connect

SELECT E.edgeID, E.edgeName, COUNT(*) AS edgeCount

FROM Node as N

INNER JOIN Connection AS C ON N.nodeID = C.nodeID

INNER JOIN Edge AS E ON C.edgeID = E.edgeID

WHERE N.nodeID = :aNodeID

GROUP BY E.edgeID, E.edgeName

ORDER BY E.edgeName;

Figure 4.11 Connection undirected graph: SQL query Find the nodes

for an edge and how often they connect

SELECT DISTINCT N.nodeID, N.nodeName, COUNT(*) AS nodeCount FROM Edge AS E

INNER JOIN Connection AS C ON E.edgeID = C.edgeID

INNER JOIN Node AS N ON C.nodeID = N.nodeID

WHERE E.edgeID = :anEdgeID

GROUP BY N.nodeID, N.nodeName

ORDER BY N.nodeName;

B c

d

e

F

A

f

g

Node table

node

ID

node

Name

Connection table

connec tionID

node ID

edge ID

udg ID

Figure 4.12 Connection undirected graph: Populated tables

Edge table

edge ID

edge Name

51 c

52 d

53 e

54 f

55 g

56 h

57 i

Connection table (cont)

connec tionID

node ID

edge ID

udg ID

Trang 4

4.2.5 Examples

Figure 4.14 illustrates the template A manufacturing plant can have a variety of equipment that is connected by piping For stress calculations, all that matters is that the equipment is connected Stress calculations ensure that piping does not break under the load of forces such

as wind and temperature changes

4.3 Undirected Graph Changing over Time Template

This template adds time intervals to the Node and Edge entity types from Section 4.1.

4.3.1 UML Template

Figure 4.15 shows the template for the node and edge undirected graphs that change over time, extending the template in Figure 4.2 The template in Figure 4.15 cannot handle edges that connect twice to the same node

A UDG (undirected graph) is a set of nodes and a set of edges that connect nodes (Note:

in an undirected graph all the nodes need not be connected.) You need not show UDG in a

Figure 4.13 Connection undirected graph: Populated tables

Node table

node

ID

node

Name

11 X

12 Y

Connection table

connec tionID

node ID

edge ID

udg ID

Edge table

edge ID

edge Name

11 r

12 s

13 t

Connection table (cont)

connec tionID

node ID

edge ID

udg ID

Y X

r s t

Figure 4.14 Connection undirected graph: Equipment and piping model

1 * Nozzle 2 1

ManufacturingPlant

1

*

Trang 5

70 Chapter 4 / Undirected Graph Template

use of the template A Node is an entity type whose records are organized as an undirected graph An Edge is a coupling between Nodes.

With this template the names of nodes and edges are globally unique There is no context

to provide an alternative approach to naming

4.3.2 IDEF1X Template

Figure 4.16 restates Figure 4.15 with the IDEF1X notation The following are foreign keys:

udgID references UDG, nodeID references Node, and edgeID references Edge In Figure 4.16 the node name can change over time (three part candidate key—nodeName + effective-Date + expirationeffective-Date), but the node name could also be invariant over time (candidate key

of nodeName alone) Similarly the edge name could be invariant over time.

4.3.3 SQL Queries

Figure 4.17 and Figure 4.18 show SQL queries for common traversals of the template The colon prefix denotes variable values that must be provided for each query With this template

an edge cannot connect twice to the same node, so there is no need to group nodes in Figure 4.18

4.3.4 Sample Populated Tables

Figure 4.19 shows tables populated with data for the node and edge undirected graph

chang-ing over time The values of the IDs are arbitrary, but internally consistent A null

effective-*

2

<UDG>

Figure 4.15 Undirected graph changing over time: UML template Use when

history must be recorded and no edges connect to the same node

<Node>

effectiveDate expirationDate

<Edge>

effectiveDate expirationDate

Figure 4.16 Undirected graph changing over time: IDEF1X template

nodeID

udgID (FK)

nodeName (AK1.1)

Node

edgeID udgID (FK) edgeName (AK1.1)

Edge

Node_Edge

nodeID (FK) edgeID (FK) effectiveDate (AK1.2)

expirationDate (AK1.3)

effectiveDate (AK1.2) expirationDate (AK1.3) udgID

UDG

Ngày đăng: 05/07/2014, 06:20

TỪ KHÓA LIÊN QUAN