Wednesday, June 07, 2017

Azure Cosmos DB Graph APIs

Introduction to Azure Cosmos DB Graph APIs | Microsoft Docs
Azure Cosmos DB graph architecture
Graph language "Gremlin"

TinkerPop3 Documentation

"A graph’s structure is the topology formed by the explicit references between its vertices, edges, and properties. A vertex has incident edges. A vertex is adjacent to another vertex if they share an incident edge. A property is attached to an element and an element has a set of properties. A property is a key/value pair, where the key is always a character String. The graph structure API of TinkerPop3 provides the methods necessary to create such a structure. The TinkerPop graph previously diagrammed can be created with the following Java 8 code. Note that this graph is available as an in-memory TinkerGraph using TinkerFactory.createClassic()."

Graph graph =; (1) Vertex marko = graph.addVertex(T.label, "person",, 1, "name", "marko", "age", 29); (2) Vertex vadas = graph.addVertex(T.label, "person",, 2, "name", "vadas", "age", 27); Vertex lop = graph.addVertex(T.label, "software",, 3, "name", "lop", "lang", "java"); Vertex josh = graph.addVertex(T.label, "person",, 4, "name", "josh", "age", 32); Vertex ripple = graph.addVertex(T.label, "software",, 5, "name", "ripple", "lang", "java"); Vertex peter = graph.addVertex(T.label, "person",, 6, "name", "peter", "age", 35); marko.addEdge("knows", vadas,, 7, "weight", 0.5f); (3) marko.addEdge("knows", josh,, 8, "weight", 1.0f); marko.addEdge("created", lop,, 9, "weight", 0.4f); josh.addEdge("created", ripple,, 10, "weight", 1.0f); josh.addEdge("created", lop,, 11, "weight", 0.4f); peter.addEdge("created", lop,, 12, "weight", 0.2f);

Alternative, a bit simpler to use, graph query language is Cypher from Neo4j.
graph databases - Neo4j - Cypher vs Gremlin query language - Stack Overflow

jbmusso/gremlin-javascript: JavaScript graph database client for TinkerPop3 Gremlin Server @GitHub
client.execute('g.V().has("name", name)', { name: 'Alice' }, (err, results) => {
  if (err) return console.error(err);

The Gremlin Graph Traversal Language @ SlideShare

Azure Cosmos DB: NoSQL capabilities everyone should know about | Build 2017 | Channel 9

How to build globally-distributed, fast, billion-user applications with Azure Cosmos DB | Build 2017 | Channel 9

No comments: