Detailed explanation of the technical principles of NEO4J database

Neo4J is a graphical database that uses graphism principles to organize and store data.Its technical principle is based on the concept of nodes and relationships, which is different from traditional relational databases.This article will introduce the technical principles of NEO4J in detail, including data models, graphical query language CYPHER, storage structure, and related programming code and configuration. 1. Data model The data model of NEO4J is mainly composed of nodes and relationships.A node represents an entity, such as a person, an article or a movie.Each node can have multiple attributes, such as name, age, or title.Relations indicate the connection between nodes.Relationships can be directed or inexperienced, or attributes.For example, a relationship can be "follow" or "like", and at the same time, there can be attributes such as "creation time" or "score". 2. Cypher query language Neo4J uses a graphic language called CyPher to search and operate data.Cypher provides rich operators and functions, and users can easily perform graphic query.For example, the query statement below will return to all nodes that follow nodes A: Match (a)-[: Follow]-> (b) RETURN B Third, storage structure Neo4J uses a storage structure based on a storage engine, called "attribute map".The attribute diagram is composed of three main components: labels, attributes, and relationships.The label is used to group information for nodes, attribute preservation nodes and relationships, and relationships represent the connection between nodes. The NEO4J's storage structure uses the method of dense two -way storage (Dense Bidirectional Storage), so that you can earn information related to nodes and relationships when querying.This structure uses an efficient data structure defined in NEO4J, called "attribute diagram storage format". Fourth, programming code and configuration Neo4J provides a variety of programming interfaces, including Java, Python, and Node.js.We can use these interfaces to interact with the database, and perform query and update operations. Here are a simple example code written in Python to create a node and add a relationship: # Import NEO4J driver program from neo4j import GraphDatabase # 连 to the database uri = "bolt://localhost:7687" Driver = Graphdatabase.driver (URI, Auth = ("Username", "Password")) # Create a session with driver.session() as session: # Create a node in the database session.run("CREATE (n:Person {name: 'John', age: 30})") # session.run("MATCH (a:Person {name: 'John'}), (b:Person {name: 'Jane'}) CREATE (a)-[:关注]->(b)") # Close database connection driver.close() The above example code uses the Python driver to connect to the NEO4J database, create a node called "Person", and add a "concern" relationship. In terms of configuration, Neo4J uses a configuration file called neo4j.conf to manage its behavior.This file contains some important configuration items, such as terminal slogans, memory allocation and security settings.By editing this file, the necessary configuration adjustment can be performed on NEO4J. In summary, NEO4J is a graphical database based on graphic principles. Its technical principles include data models, CYPHER query language, storage structure, and related programming code and configuration.By understanding the technical principles of NEO4J in depth, we can better understand and apply this powerful database.