# Docker 安装 Neo4j图数据库
Neo4j图数据库组成模块:
- 节点
- 属性
- 关系
- 标签
- 数据浏览器
# 1.安装
docker run -d --name neo4j \
-p 7474:7474 -p 7687:7687 \
-v /home/neo4j/data:/data \
-v /home/neo4j/logs:/logs \
-v /home/neo4j/conf:/var/lib/neo4j/conf \
-v /home/neo4j/import:/var/lib/neo4j/import \
--env NEO4J_AUTH=neo4j/neo4j@123456 \
neo4j
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 2.使用
1. CREATE
CREATE (
<node-name>:<label-name>
[{
<property1-name>:<property1-Value>
........
<propertyn-name>:<propertyn-Value>
}]
)
CREATE(person:Person {cid:1,name:"范闲",age:24,gender:0,character:"A",money:1000})
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
2. MATCH RETURN
MATCH
(
<node-name>:<label-name>
)
RETURN
<node-name>.<property1-name>,
...
<node-name>.<propertyn-name>
MATCH(person:Person) RETURN person
MATCH(person:Person) RETURN person.name,person.age
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
3. 关系创建
# 现有节点创建关系
MATCH (<node1-label-name>:<node1-name>),(<node2-label-name>:<node2-name>)
CREATE
(<node1-label-name>)-[<relationship-label-name>:<relationship-name>
{<define-properties-list>}]->(<node2-label-name>)
RETURN <relationship-label-name>
match(person:Person {name:"范闲"}),(person2:Person {name:"林婉儿"})
create (person)- [r:Couple{mary_date:"2020/12/12"}]->(person2)
#使用新节点创建关系
CREATE
(<node1-label-name>:<node1-name>{<define-properties-list>})
-[<relationship-label-name>:<relationship-name>{<define-properties-list>}]
->(<node1-label-name>:<node1-name>{<define-properties-list>})
create(person1:Person {cid:9,name:"靖王世子",age:23,gender:0,character:"A",money:3000})
-[r:Friend {date:"2020/11/2"}]->
(person2:Person {cid:8,name:"二皇子",age:24,gender:0,character:"B",money:4000})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21