Reputation: 426
I am new to neo4j database. I was looking for graph based database and found neo4j interesting. I wanted to know if it is possible to query neo4j database in Relational database style. Let me explain myself with an example:
I have a graph database of all students in class. Nodes contain student information and the relationships are 'friendship'. Each node has properties like name of student, class and cgpa. Now I want to get list of all students whose cgpa > 4. Is it possible to do this in neo4j in single query? Or do I need to find all nodes and then manipulate them?
It would also be very helpful if anyone can point out some good resource for neo4j queries.
Upvotes: 3
Views: 1062
Reputation: 1234
I always worked with the Neo4j docs. If you are using Spring Data Neo4j, the free book Good Relationships may also help.
There is a query language called Cypher. There are even some examples in the documentation which may fit pretty good to your case [1]:
start n=(2, 1) where n.age < 30 return n
This one starts on the given nodes with id 2 and 1 and returns them if their age property is below 30. start n=(*)
would do it for every node. You should read the whole specifications.
Depending on what you do and how you want to find specific nodes, you can use indices.
However, you should not use a graph database the same way as a relational one. For your described scenario it might be ok, but try to design the relations in a way that you can use them later on for your traversals. It is much faster.
Upvotes: 2