Top 10 Interview Questions for Neo4j Graph Database
by Nithyanandham, on Sep 11, 2022 3:13:03 PM
Q1. Explain what is Neo4j?
Ans: Neo4j is an open source NOSQL graph database, implemented in Java. It saves data structured in graphs rather than in tables.
Q2. For what Neo4j is widely used for?
Ans: Neo4j is widely used for
- Highly connected data – Social Network
- Recommendation- ( e-coomerce)
- Path Finding
- Data First Schema (bottom-up)
- Schema Evolution
- A* (Least Cost Path)
Q3. What can you delete databases in Neo4J?
Ans: If you want to delete/remove entire graph directory you can use command rm -rf data/*as such Neo4j is not storing anything outside that.
Q4. Mention some of the important characteristics of neo4j?
Ans: Some important characteristics of neo4j includes
- Materializing of relationship at creation time, resulting in no penalties for runtime queries
- Continuous time traversals for relationship in the graph both in breadth and depth due to double linking on the storage level between nodes and relationships
- Relationship in Neo4j is fast and make it possible to materialize and use new relationships later on to “shortcut” and speed up the domain data when new requirement arise
- It can do memory caching for graphs and provides compact storage, resulting in efficient scale-up
- It is written on the top of JVM
Q5. Explain the role of building blocks like Nodes, Relationships, Properties and Labels in Neo4j?
Ans: The role of building blocks
- Nodes: They are entities
- Relationship: It connects entities and structure domain
- Properties: It consists of meta-data and attributes
- Labels: It group nodes by role
Q6. Explain how you can run CQL commands in Neo4j?
Ans: You use “$” prompt to run all CQL commands in Neo4j.
Q7. Mention what are the different types of object caches in Neo4j?
Ans: There are two different types of object caches in Neo4j
- Reference Caches: With this cache, Neo4j will use as much as allocated JVM heap memory as it can hold nodes and relationships
- High-performance Caches: It get assigned a certain maximum amount of space on the JVM heap and will delete objects whenever it grows bigger than that.
Relationship and Nodes are added to the object cache as soon as they are accessed
Q8. Mention which query language does Neo4j use and what is consist of?
Ans: Neo4j uses Cypher query language, which is unique to Neo4j. Traversing the graph requires to know where you want to begin (Start), the rules that allow traversal (Match) and what data you are expecting back (Return). The basic query consists of
- START n
- MATCH n-[r]- m
- RETURN r;
Ans: As such Neo4j got RESTful API, you can query over the web, or you can run it locally. It runs in the Heroku or Cloud.
Q10. Explain how you can create/delete databases in Neo4j?
Q11. Explain how Neo4j can be helpful in detecting Brute Force Attack?
Ans: Neo4J allows to store and retrieve multiple complex relations. The capability of Neo4j to do complex query in real time is really helpful in identifying a brute force attack much quicker. The most crucial thing in detecting such attacks is to capture enough information about each requests like
- Client real IP address and not the proxy one
- Login failure or attempt success information
- Timestamp
Q12. Mention how indexing is done in Neo4j?
Ans: There was no indexing in earlier days for Neo4j, but later on it was introduced with new feature Automatic Indexes by using the command
START n=node:node_auto_index(name=‘abc’) RETURN n
Q13. Mention how files are stored in Neo4j?
Ans: Neo4j stores graph data in a number of different store files, and each store file consists of the data for a specific part of the graph for example relationships, nodes, properties etc. for example Neostore.nodestore.db, neostore.propertystore.db and so on.
Q14. Mention what Neo4j CQL command is used for?
Ans: Neo4j CQL command can be used for
- To create nodes with and without properties
- To create a relationship between nodes with properties
- To create a relationship between nodes without properties
- To make multiple or single labels to a Node or a Relationship
Q15. Explain what Neo4j CQL MATCH command is used for?
Ans: The CQL MATCH command in NEO4j is used for
- To get data about properties and nodes from the database
- To get data about relationship, nodes and properties from the database
Q16. Explain what is the MATCH command syntax and what is the rule for using it?
Ans: The syntax for MATCH command is
MATCH
(
<node-name>:<label-name>
)
The rule for using MATCH command is that you cannot use this command alone to fetch data from the database otherwise it will show invalid syntax error.
Q17. Explain what does the SET clause is used for in Neo4j?
Ans: Neo4j CQL use SET clause for the following purpose
- Update or Add properties values
- Add new properties to existing Relationship or Node
Q18. Explain what Neo4j CQL LIMIT clause is used for?
Ans: Neo4j CQL LIMIT clause is used for limit or filter the number of rows return by a query.
Q19. Mention the IN Operator syntax in Neo4i?
Ans: The IN Operator syntax in NEO4j would be something like this
IN[ <Collection-of-values>]
Q20. Explain how Neo4j stores primitive array?
Ans: Neo4j stores primitive array in a compressed way in order to save the space on disk, to do that it uses a “bit saving” algorithm.
Q21. Why Neo4J is called graph database?
Ans: Neo4J is called graph database because it saves data structure in graph rather than in tables.
Q22. In which language Neo4G is written?
Ans: Neo4J is written and implemented in Java language.
Q23. Which query language is used by Neo4J?
Ans: Cypher Query Language (CQL) is used by Neo4J.
Q24. Which was the Neo4J first version and when was it released?
Ans: The first version of Neo4J was Neo4j 1.0 and it was released in Feb, 2010.
Q25. In which cases Neo4J is widely used?
Ans: Neo4J is widely used for ?
- Highly connected data ? Social Network
- Recommendation- ( e-commerce)
- Path Finding
- Data First Schema (bottom-up)
- Schema Evolution
- A*(Least Cost Path)
Q26. Why is SET clause used for in Neo4J?
Ans: In Neo4J CQL, SET clause is used for following purposes:
- Update or Add properties values.
- Add new properties to existing Relationship or Node.
Ans: 27. Is it possible to query Neo4j over the internet?
As such Neo4j got RESTful API, you can query over the web, or you can run it locally. It runs in the Heroku or Cloud.