Network O&M scenario
Graph Database (GDB) lets you easily model large amounts of IT and network operations data by transforming structured data from relational databases into nodes and edges. This process reduces the data modeling workload for database administrators (DBAs) and improves query efficiency. GDB solves problems found in traditional solutions. Traditional databases often cannot handle data volumes beyond a certain limit, and a Configuration Management Database (CMDB) can be time-consuming and inflexible.
The following example uses the USAir97 airport transportation dataset to demonstrate a specific application.
Example diagram
The following figure shows the connections of a hub node.
Example data model
The graph data model represents each airport terminal as a node and the transportation routes between them as edges. In this model:
Nodes contain the terminal name and coordinates.
Edges contain the connected terminals and the distance between them.
Code examples
You can view the total number of points.
g.V().count()Query the total number of edges.
g.E().count()Query the number of nodes that connect to the hub node.
g.V('118').in().count() // 118 is the "Chicago O'hare Intl" node.What are the available access nodes?
g.V('118').in().id()The following result is returned:
65 //"Portland Intl" 94 //"General Mitchell Intll" 95 //"Greater Buffalo Intl" 8 //"Anchorage Intl" ...Query the number of nodes that the hub node connects to.
g.V('118').out().count()Query the specific nodes that the hub node connects to.
g.V('118').out().id()The following result is returned:
201 //"San Francisco Intl" 221 //"Raleigh-Durham Intll" 301 //"Tampa Intl" 232 //"Memphis Intl" ...Query the optimal transportation path from the "Wiley Post-Will Rogers Mem" node to the "Shreveport Regional" node.
g.V("1").store("x").repeat(out().where(without("x")).aggregate("x")).until(hasId("267")).path()The following result is returned:
[v[1],v[4],v[47],v[255],v[267]] // "Wiley Post-Will Rogers Mem" -> "Fairbanks Intl" -> "Seattle-Tacoma Intl" -> "The William B Hartsfield Atlan" -> "Shreveport Regional"Analyze transportation route statistics. You can add a cargo event record for each transport to a node. This lets you query transportation routes by cargo to compile route statistics, track cargo, and retrieve cargo information.
g.V('1').property('cargo1', 1) g.V().properties('cargo1').valueMap(true)The following result is returned:
v[1] [id:1,key:cargo1,value:1] [id:4,key:cargo1,value:2] [id:47,key:cargo1,value:3]Track cargo transportation routes. You can use markers in the graph database to track a cargo's path through the transport network. This tracking can be done during or after transport.
g.V().has("cargo1").valueMap(true)The following result is returned:
[id:1,label:vertex,cargo1:[1]] [id:4,label:vertex,cargo1:[2]] [id:47,label:vertex,cargo1:[3]]