Adding data to a graph in DataStax Studio
-
Create the schema.
To add data to a graph from a cell in your notebook:
-
Add four more vertices and two other edges:
user = graph.addVertex(label, 'user', 'id', 2, 'name', 'Jay Quest', 'role', 'customer') product = graph.addVertex(label, 'product', 'id', 3, 'name', 'digital camera') user.addEdge('bought', product) user = graph.addVertex(label, 'user', 'id', 3, 'name', 'Bartholmew Hicks', 'role', 'employee') product = graph.addVertex(label, 'product', 'id', 4, 'name', 'eraser') schema.edgeLabel('manufactured').create() user.addEdge('manufactured', product) g.V()
Graph studio instance with four vertices and two edges -
Create an edge between two existing vertices:
-
Add this code to a new Gremlin cell:
user = g.V().has('user', 'name', 'Jo Dowe').next() product = g.V().has('product', 'name', 'eraser').next() user.addEdge('bought', product) g.V()
-
Switch the cell to display a graph.
-
Select the Jo Dowe user vertex.
gsDoweEraser
-