As the world's advanced graph database, Neo4j has become the first of many Internet companies nowadays.
As the world's advanced graph database, Neo4j has become the first of many Internet companies nowadays.
As the world's advanced graph database, Neo4j has become the first choice for many Internet companies. Neo4j is an open source graph database developed based on java and also a NoSQL database. While ensuring a good characterization of data relationships, Neo4j also supports ACID features of traditional relational data, and has a good performance in terms of storage efficiency, cluster support, and failover. Recently, due to the relationship between lab projects, we have some knowledge about Neo4j. At the same time, I am also very interested in its design ideas and architecture. Therefore, I wrote this blog to help you better understand this database and share my understanding with you.
Design Concept
Neo4j is designed to better and more efficiently describe the relationships between entities. In real life, every entity is closely related to other entities. The information stored in these relationships is even greater than the attributes of the body. Then, traditional relational databases focus more on describing the internal properties of entities. The relationships between entities are usually implemented using foreign keys. Therefore, the join operation is usually required when solving the relationship, and the join operation is usually time-consuming. The explosive growth of the Internet, especially the mobile Internet, has overwhelmed traditional relational databases. Coupled with the high demand of applications such as social networks for relationships, it can be said that relational databases have no advantage. As a database that focuses on describing the relationship between data, graph databases have become a very important part of NoSQL. Neo4j is one of the most outstanding graph databases.
There are only two types of data in the Neo4j database:
- Node: the Node is similar to the entity of the E-R graph, each entity can have 0 to multiple attributes that exist in the form of a key-value pair, you do not need to define attributes in advance. In addition, each node can be tagged to distinguish different types of nodes.
- Relational Relationship: a relational relationship is similar to a Relationship of a E-R. A relational relationship consists of a starting node and a ending node. In addition, like node, the link can also have multiple attributes already labeled
The specific structure is as follows: an actual graph database example is shown in the following figure:
Based on this design philosophy, Neo4j has the following features: <喎?http: www.2cto.com kf ware vc " target="_blank" class="keylink"> Response + response/response + response/0rvOu7XEvt/M5dLi0uXI58/Co7o8L3A + response + s/08bGk + response + 1aWQ8bGk + response + release + 1aWQ8bGk + release + 1 aWQKPHA + z + DQxb + release + zBy6Os0vLOqsO/release + release/release + tNO92rXjMb + qyryjrL/ttsjTxc/IsenA + release/release + + release/Zub2RlMzxsaT7Tw9Payc/OxM/release + 1 + 66873hufvI58/Co7oKPGJsb2NrcXVvdGU + Cgo8cHJlIGNsYXNzPQ = "brush: SQL; "> (1)-[KNOWS, 2]-> (4) (1)-[KNOWS, 1]-> (3) (1)-[KNOWS, 0]-> (2) (1)-[KNOWS, 1]-> (3)-[KNOWS, 5]-> (7) (1)-[KNOWS, 1]-> (3)-[KNOWS, 4]-> (6) (1)-[KNOWS, 1]-> (3)-[KNOWS, 3]-> (5)Differences between Neo4j and relational databases
In fact, through the above explanation, I believe everyone has a certain understanding of the difference between neo4j and RDBMS (Relational Database Management System). Now I will repeat it with the following table:
Neo4j |
RDBMS |
Allow simple and diverse management of data |
Highly structured data |
Flexible data addition and definition, not limited by data types and quantities, no need to be defined in advance |
Table schema needs to be predefined. It is complex to modify and add data structures and types, and has strict restrictions on data. |
Relational query operations with constant time |
Link query operation time |
The new Query Language cypher is proposed, which makes the query statement simpler. |
Query statements are more complex, especially when join or union operations are involved. |
The following two figures show the differences between the two in the query relationship: RDBMSNeo4j
The specific installation and use of Neo4j is not the focus of the Article. If you want to use Neo4j, you can go to the official website of Neo4j with a lot of information.