NEO4J database for initial knowledge of database

Source: Internet
Author: User
Tags neo4j
Graphdatabase

Diagram database of notes neo4j diagram database What is diagram database why use diagram database neo4j download install cypher Query Language neo4j All kinds of API transaction NEO4J data modeling large-scale data import neo4j c3>. What is a diagram database keywords: storage graph structure data, NoSQL
Basic elements of neo4j (tectonic unit): nodes, relationships, attributes



two. Why use the diagram database

Maximum advantage: High performance of query
An example is provided:
Rdbms-mysql VS. Graph db-neo4j
Social network relational data storage in a relational database



Querying a friend of a user's friends: using a INNER JOIN operation
For example, check out Friends of 2 friend:

SELECT * FROM T_user_friend uf1 inner join t_user_friend uf2 on uf1.user_1 = uf2.user_2 where uf1.user_2 = 2;


Generally do to go to the heavy operation. It can be learned that 2 of friends 1 of Friends is 4.
If you want to query a friend of a user's friends, that is, a 3-degree relationship

SELECT DISTINCT * t_user_friend uf1 inner join t_user_friend uf2 on uf1.user_1 = uf2.user_2 inner
join T_USER_FRI End uf3 on uf2.user_1 = uf3.user_2  
where uf1.user_2 = 2;


In other words, in a large number of complex data conditions, want to query deeper relationships, you must use more join operations, and a large number of
Join operations seriously affect the performance of relational databases.

Graph database is good at many pairs of relationships, without tables, columns, foreign keys, directly to store users as nodes, to the relationship between users
Organize these nodes, query the direct use of the graph traversal algorithm, very efficient.
three. Download and installation of neo4j

Download Address:
https://neo4j.com/download/community-edition/


Individuals usually use the Community edition, the Java Virtual machine must be installed before installing NEO4J, NEO4J installation has two kinds of ways:
-Compact installation (. Tar,.zip)
-Installation version installation (Dmg,exe) Recommendation

NEO4J support for local and remote access:
-There are three ways to connect remotely:
-Bolt Connection mode
-HTTP connection mode
-HTTPS connection mode (HTTPS requires security certificate support to allow the database to be used when accessing in the extranet)

Modify the configuration file when using neo4j.conf, there are tutorials on the Internet, there are also on the official web.
After installation, start the server, and then we can access the server through the Web console.
http://localhost:7474
http://server ip:7474
Quick experience: Experience with Cypher Query language in the Web console
four. Cypher Query Language

relational databases have SQL query language, structured query Language.
NEO4J owns CQL, the Cypher Query Language, and the keyword draws on languages such as SQL,SPARQL and Python.

Where cypher can be used.
-Neo4j-shell
-Web Console
-Neo4j API
-Rest API

What the cypher syntax includes.
-Read and Write
-Index
-Constraints
-Tags
-read-only query
-CASE Clause
-Traversal path
-function
-Call calls the stored procedure

https://neo4j.com/docs/cypher-refcard/current/
https://neo4j.com/docs/developer-manual/3.2/cypher/
Five. Neo4j's various APIs

Two ways to use neo4j: embedded mode, server mode
-Embedded Mode:
-only need to refer to the NEO4J development package. It is generally introduced in the Pom.xml file of the MAVEN project without the need to turn on the neo4j server.
-Neo4j API
-Server Mode:
-You must first install and start the NEO4J server, and then introduce the neo4j driver. It is also introduced in the Pom.xml file of the MAVEN project.
-REST API
-Traverse the frame:
-Traversal Framework Java API
Https://neo4j.com/docs/java-reference/3.2/
six. The transaction

When using the NEO4J API, you need to turn on transaction management regardless of the operation. This means that the program that operates the database must be written in the following code snippet:

Try (Transaction tx = Graphdb.begintx ()) {
...
Tx.success ();
}

Do not forget to close the database after you have finished using the database.

To maintain data integrity and ensure good transactional behavior, neo4j also supports ACID properties:
-Atomicity: All operations in a whole transaction, either complete or incomplete, cannot be stalled in the middle of the process. An error occurs during the execution of a transaction and is rolled back (Rollback) to the state before the transaction began, as if the transaction had never been performed.
-Consistency: Database integrity restrictions are not compromised until the transaction is started and after the transaction has ended.
-Isolation: Two transactions are performed without interference, and one transaction cannot see the data at a time when other transactions are running.
-Persistence: After the transaction is completed, changes made to the database by the transaction are persisted in the database and are not returned.
-In addition to the above transaction characteristics, NEO4J also has its own special rules. Seven. neo4j Data Modeling (the understanding is also vague here)

In different ways, modeling strategies use nodes, relationships, attributes, and tags to model.
-A simple model in a specific area can be built using NEO4J-OGM
http://blog.csdn.net/xqclll/article/details/60578982
-Use Java core API eight. Large data import neo4j cypher load CSV official Java Api--batch inserter Batch Import Tool Https://my.oschi na.net/u/2538940/blog/883829 Official Neo4j-import Tools

http://blog.csdn.net/xingxiupaioxue/article/details/71747284

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.