0、概述
通过该案例,应用Cypher查询语言,感受Neo4j套路。官方的用此案例的用意:
The Northwind Graph demonstrates how to migrate(迁移) from a relational database to Neo4j(把一个负责的多表关系数据库关系等价转化为图数据中,并且查询表现出巨大的优势). The transformation is iterative and deliberate, emphasizing the conceptual shift from relational tables to the nodes and relationships of a graph.
This guide will show you how to:
- Load: create data from external CSV files(加载数据)
- Index: index nodes based on label
- Relate: transform foreign key references into data relationships
- Promote: transform join records into relationships
1、找到位置
:play start
弹出如下界面:
![](https://img-blog.csdnimg.cn/20200323185427450.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3l1ZWJvd2h1,size_16,color_FFFFFF,t_70)
点击中间的“Jump into code”,进入到如下界面:
![](https://img-blog.csdnimg.cn/20200323185608591.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3l1ZWJvd2h1,size_16,color_FFFFFF,t_70)
这里有Movie Graph和Northwind Graph两个案例,这里演示第二个案例。
2、 Load: create data from external products CSV files
LOAD CSV WITH HEADERS FROM "http://data.neo4j.com/northwind/products.csv" AS row
CREATE (n:Product)
SET n = row,
n.unitPrice = toFloat(row.unitPrice),
n.unitsInStock = toInteger(row.unitsInStock), n.unitsOnOrder = toInteger(row.unitsOnOrder),
n.reorderLevel = toInteger(row.reorderLevel), n.discontinued = (row.discontinued