This database is more scalable graph database. Lets get to know how to get started with Titan Graph Database.
First download Titan from Titan Site
Click Here to download Titan Graph Database
Then extract titan to a disk. In this example I take D drive. If you are Linux user extract this Titan file to somewhere you can execute.
Then take a shell in Linux or command prompt in Windows. Then move to titan folder. Then move to bin.
Before take Gremlin Console you need to install Java.
After that if you are Linux guy run this command.
bash gremlin.shOr if you are windows guy you command is,
Now you are having gremlin. Now we are going to connect to graph database. Basically Titan we can use with three main storage backends. They are
- Oracle Berkley
g = TitanFactory.open('local/tmp');Below command will initiate a graph and assign it to g variable. Now in you bin you can see local and temp folders are created.
If you hope to search through your graph in Titan you have to index it first. Otherwise you can't search it. Actually it's a bug like thing in titan, and it's a know issue. Let say we are going to search with "name" property. Then we have to add "name" index first.
Now you are ready to add nodes and edges. And you have a index on "name" property.
v = g.addVertex(null);This will create a new node on graph. we are going to set properties to this node.
v1 = g.addVertex(null);
v2 = g.addVertex(null);
v2.setProperty('type','institute');Now we have three nodes. Two of them are Persons and the other one is a institute. Now we are going to create relationships between those three nodes.
e1 = g.addEdge(null, v, v2, 'study in');
e2 = g.addEdge(null, v1, v2, 'study in');
e3 = g.addEdge(null, v, v1, 'knows');
e4 = g.addEdge(null, v1, v, 'knows');
Now you have a graph like this.
Now we are going to have a journey around our beautiful data!!! And now I want to know where malinda "study in". For that I have to load Malinda to a vertex variable. I'll use existing one.
Now I want who study in UCSC. For that I have to load UCSC to a variable first. I'll use existing one.
If I only need names of them then below one is the command.
v2.in('study in').name;Finally to commit all those thing to disk you have to shutdown the graph for that run below command.
Be careful those commands are case sensitive!!! Enjoy Graphs!!!