当前位置:网站首页>Figure introduction to database neo4j
Figure introduction to database neo4j
2022-06-13 09:05:00 【Q z1997】
1. Graph database Neo4j Introduce
1.1 What is graph database (graph database)
With social interaction 、 Online retailers 、 Finance 、 retail 、 Rapid development of Internet of things and other industries , The real society has formed a huge and complex network of relations , Traditional database is difficult to deal with relational operation . The relationship between the data to be processed in big data industry grows geometrically with the amount of data , There is an urgent need for a database that supports massive and complex data relational operations , Figure database came into being . Many famous companies in the world are using graph database , such as :
- Social sphere :Facebook, Twitter,Linkedin Use it to manage social relationships , Realize friend recommendation
- Retail area :eBay, Wal Mart uses it to realize real-time recommendation of goods , Better shopping experience for buyers
- Financial field : Morgan chase , Citigroup, UBS and other banks are using graph database for risk control
- Automotive manufacturing : Volvo , Top automakers such as Daimler and Toyota rely on graphic databases to drive innovative manufacturing solutions
- Telecom field :Verizon, Orange and AT&T And other telecom companies rely on graph database to manage the network , Control access and support customers 360
- Hotel Area : Top hotel companies, such as Marriott and Accor hotels, manage complex and rapidly changing inventory map databases by using map databases, which do not refer to databases that store pictures , Instead, data is stored and queried in a graph data structure .
Graph database is a kind of database based on graph theory NoSQL database , Its data storage structure and data query method are based on graph theory , Graph database is mainly used to store more connection data .
graph theory 〔Graph Theory〕 It's a branch of mathematics . It takes graph as its research object. Graph in graph theory is a graph composed of several given points and lines connecting two points , This kind of graph is usually used to describe a certain relationship between certain things , Use dots to represent things , A line connecting two points indicates that there is such a relationship between two things .
Use Google+(GooglePlus) Applications to understand the real world Graph Database requirements . Look at the chart below . ad locum , We use circles to show Google+ Apply profile .
In the diagram above , outline “A” Have circles to connect to other outlines : Family circle (B,C,D) With friends (B,C). Again , If we open the configuration file “B”, We can observe the following connected data .
like this , These applications contain a large number of structured , Semi structured and unstructured connected data . stay RDBMS It is not easy to represent such unstructured connected data in a database . If we were RDBMS This more connected data is stored in the database , So retrieval or traversal is very difficult and slow . So you want to represent or store this more connected data , We should choose a popular graph database .
The graph database can easily store this more connected data . It stores each profile data internally as a node , The nodes that it connects to adjacent nodes , They are connected by relationships . They store the same data for this connection as in the chart above , This is very easy and faster to retrieve or traverse .
Relationship query performance comparison In the data relationship Center , Graph database is very efficient in query speed , Even for deep and complex queries . In relational database and graph database (Neo4j) The experiment was carried out between : The maximum depth found in a social network is 5 Friends of friends of , Their datasets include 100 ten thousand people , About everyone. 50 A friend .
The experimental results are as follows :
Compare relational databases 
In a relational database ,Person and Department The relationship between tables is represented by foreign keys :

Compare with others NoSQL database
NoSQL Databases can be roughly divided into four categories :
- Key value (key/value) database
- Column store database
- Document database
- Graph database


1.2 What is? Neo4j
Neo4j It's an open source NoSQL Graphic database ,2003 Development started in , Use scala and java Language ,2007 Launched in .
- It is one of the most advanced graph databases in the world , Provide native graph data storage , Retrieve and process ;
- Adopt attribute graph model (Property graph model), Greatly improve and enrich the graph data model ;
- Proprietary query language Cypher, intuitive , Efficient ;
Official website : https://neo4j.com/
Neo4j Characteristics of :
- SQL It's like a simple query language Neo4j CQL
- It follows the attribute graph data model
- It uses Apache Lucence Support the index
- It supports UNIQUE constraint
- It contains a for executing CQL Ordered UI:Neo4j Data browser
- It supports complete ACID( Atomicity , Uniformity , Isolation and persistence ) The rules
- It uses native graphics library with native GPE( Graphics engine )
- It supports the export of query data to JSON and XLS Format
- It provides REST API, It can be used in any programming language ( Such as Java,Spring,Scala etc. ) visit
- It provides access to any UI MVC frame ( Such as Node JS) Access to the Java Script
- It supports two kinds of Java API:Cypher API and Native Java API To develop Java Applications
Neo4j The advantages of :
- It's easy to represent connected data
- retrieval / Traverse / Navigating more connected data is very easy and fast
- It's very easy to represent semi-structured data
- Neo4j CQL Query language command is a human readable format , It's very easy to learn
- Use a simple and powerful data model
- It doesn't need complex connections to retrieve connected / Relevant data , Because it's easy to retrieve its neighbor node or relationship details without connection or index
1.3 Neo4j Data model
The basis of graph theory
A graph is a set of nodes and the relationships that connect them , Graphs store data in nodes and relationships in the form of attributes , Attributes are key value pairs used to represent data .
In graph theory , We can represent a node with a circle , The relationship between nodes is marked by an arrow .
The simplest possible graph is a single node :
We can use nodes to represent social networks ( Such as Google+(GooglePlus) The personal data ), It does not contain any attributes . towards Google+ Add some attributes to your profile :
Create a relationship between two nodes :
Here you create the relationship name between the two profiles “ Follow ”. It means Profile-I follow Profile-II.
Attribute graph model
Neo4j The graph database follows the attribute graph model to store and manage its data .
Attribute graph model rules
- Representation node , Data in relationships and properties
- Both nodes and relationships contain attributes
- Relationship connection nodes
- Property is a key value pair
- Nodes are represented by circles , Relations are represented by direction keys .
- Relationships have directions : One way and two way .
- Each relationship contains “ Start node ” or “ From the node ” and “ To the node ” or “ The end node ”
In the attribute graph data model , The relationship should be directed . If we try to create relationships that have no direction , Then it will throw an error message . stay Neo4j in , Relationships should also be directional . If we try to create relationships that have no direction , that Neo4j An error message will be thrown ,“ Relationships should be directional ”.
Neo4j A graph database stores all its data in nodes and relationships , We don't need any extra RDBMS A database or NoSQL Database to store Neo4j Database data , It stores data in the form of graphs .Neo4j Use this machine GPE( Graphics engine ) To use its native graph storage format .
Figure the main building blocks of the database data model are :
- node
- Relationship
- attribute
An example of a simple attribute graph :
Here we use circles to represent nodes . Use arrows to indicate relationships , Relationships are directional . We can use Properties( Key value pair ) To express Node The data of . In this case , We are Node Of Circle Each... Is represented in Node Of Id attribute .
1.4 Neo4j Build elements for
Neo4j The diagram database mainly has the following building elements :
- node
- attribute
- Relationship
- label
- Data browser

node
node (Node) Is a basic element in the graph database , Used to represent an entity record , Like a record in a relational database . stay Neo4j The middle node can contain multiple attributes (Property) And multiple tags (Label).
- Node is the main data element
- Nodes are connected to other nodes through relationships
- A node can have one or more attributes ( namely , Store as key / Property of value pair )
- A node has one or more labels , Used to describe its role in the chart
attribute
attribute (Property) Is a key value pair used to describe graph nodes and relationships . among Key Is a string , Values can be by using any Neo4j Data type
- Property is a named value , Which name ( Or key ) Is string
- Properties can be indexed and constrained
- Composite indexes can be created from multiple properties
Relationship
Relationship (Relationship) It is also the basic element of graph database . When a node already exists in the database , The nodes need to be connected to make up the diagram . A relationship is used to connect two nodes , Relation is also called the edge of graph theory (Edge) , Its start and end must be nodes , Relationships cannot point to or originate from emptiness . A relationship can contain multiple attributes like a node , But there can only be one type of relationship (Type) .
- Relationship connects two nodes
- Relationships are directional
- Nodes can have multiple or even recursive relationships
- A relationship can have one or more properties ( Stored as key / Property of value pair )
- Based on directionality ,Neo4j Relationships are divided into two main types :
- One way relationship
- Two way relationship
label
label (Label) Associate a common name with a set of nodes or relationships , A node or relationship can contain one or more tags . We can create new labels for existing nodes or relationships , We can delete tags from existing nodes or relationships .
- Tags are used to group nodes
- A node can have multiple labels
- Index tags to speed up finding nodes in a graph
- Native Tag Index optimized for speed
Neo4j Browser
Once we install Neo4j, We can visit Neo4j Data browser
http://localhost:7474/

1.5 Use scenarios
Fraud detection 
Real time recommendation engine 
Knowledge map 
Anti money laundering 
Master data management

Supply chain management 
Enhance the network and IT Operation management capability 
Identity and access management 
边栏推荐
- torch. How to calculate addmm (m, mat1, mat2)
- QML compilation specification
- 【安全】零基础如何从0到1逆袭成为安全工程师
- 15. copy constructor
- Cesium displays a pop-up box at the specified position and moves with the map
- MySQL startup error: innodb: operating system error number 13 in a file operation
- 20220524 如何把CoppeliaSim安装到D盘
- Collection of various books
- JUC Unsafe
- output. Interpretation of topk() function
猜你喜欢

【网络安全渗透】如果你还不懂CSRF?这一篇让你彻底掌握

Redirect vulnerability analysis of network security vulnerability analysis

Tutorial (5.0) 02 Management * fortiedr * Fortinet network security expert NSE 5

网络安全漏洞分析之重定向漏洞分析

Neo4j - CQL use

CAS无锁

Cesium achieves sunny, rainy, foggy, snowy and other effects

Cmake Learning Series I

How excel adds hyperlinks to some text in a cell

线上调试工具Arthas高级
随机推荐
Judgment of single exclamation point and double exclamation point in JS
教程篇(5.0) 03. 安全策略 * FortiEDR * Fortinet 网络安全专家 NSE 5
Tutorial (5.0) 01 Product introduction and installation * fortiedr * Fortinet network security expert NSE 5
线上调试工具Arthas高级
20211018 一些特殊矩阵
【QNX Hypervisor 2.2 用户手册】4.5.1 构建QNX Guest
Summary of the first retrospective meeting
20211115 矩阵对角化的充要条件;满秩矩阵不一定有n个线性无关的特征向量;对称矩阵一定可以对角化
教程篇(5.0) 02. 管理 * FortiEDR * Fortinet 网络安全专家 NSE 5
Tutorial (5.0) 04 Fortint cloud services and scripts * fortiedr * Fortinet network security expert NSE 5
20220524 how to install coppeliasim to disk D
JS obtain geographic location information according to longitude and latitude and mark it on the map
20211108 observable, controllable, stable and measurable
Can I open an account for the reverse repurchase of treasury bonds? Can I directly open the security of securities companies on the app for the reverse repurchase of treasury bonds? How can I open an
Module build failed: TypeError: this. getOptions is not a function at Object. stylusLoader
Cesium achieves sunny, rainy, foggy, snowy and other effects
VBA format word (page, paragraph, table, picture)
Collection of garbled code problems in idea development environment
turf. JS usage
Neo4j Environment Building