作业:利用Neo4j构建图片所示内容,熟悉Cypher查询语言
知识体系图谱如下图:
1.创建"知识"节点:
CREATE(:knowledge{name:"Python基础"}),(:knowledge{name:"Requests"}),(:knowledge{name:"bas4"}),(:knowledge{name:"Scrapy"}),
(:knowledge{name:"MySQL"}),(:knowledge{name:"文件处理"}),(:knowledge{name:"Flask"}),(:knowledge{name:"Django"}),
(:knowledge{name:"MongoDB"}),(:knowledge{name:"Hive"}),(:knowledge{name:"HBase"}),(:knowledge{name:"Scala"}),(:knowledge{name:"Spark"}),
(:knowledge{name:"Hadoop"}),(:knowledge{name:"JAVA"}),(:knowledge{name:"Flink"}),(:knowledge{name:"Storm"}),(:knowledge{name:"kafka"}),
(:knowledge{name:"flume"}),(:knowledge{name:"网络"}),(:knowledge{name:"Xpath"}),(:knowledge{name:"CSS"}),(:knowledge{name:"HTML"}),
(:knowledge{name:"Linux"}),(:knowledge{name:"Windows办公软件"}),(:knowledge{name:"所属行业的业务知识"}),(:knowledge{name:"统计"}),
(:knowledge{name:"高数"}),(:knowledge{name:"机器学习"}),(:knowledge{name:"深度学习"})
2.创建“岗位”节点
CREATE(:job{name:"自动化办公"}),(:job{name:"Web开发"}),(:job{name:"爬虫"}),(:job{name:"数据分析"}),(:job{name:"人工智能"}),
(:job{name:"大数据"})
3.创建“岗位方向”节点
CREATE(:direction{name:"离线计算"}),(:direction{name:"实时计算"}),(:direction{name:"视觉"}),(:direction{name:"语音"}),
(:direction{name:"NLP"}),(:direction{name:"推荐"})
4.创建节点间的关系
求教!! 这里添加关系的时候,用初的写法写了很多句,需要一条一条的执行,很low,请教各位大神!请不吝赐教!
1.有没有办法把,这么多句,写成一条Cypher;
2.有没有更的方法?
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"Requests"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Requests"}),(n2:knowledge{name:"bas4"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"bas4"}),(n2:knowledge{name:"Scrapy"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Scrapy"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Scrapy"}),(n2:knowledge{name:"MongoDB"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"文件处理"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"文件处理"}),(n2:knowledge{name:"Flask"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"文件处理"}),(n2:knowledge{name:"Django"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Flask"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Django"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"MongoDB"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"Hive"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"HBase"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"自动化办公"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"Web开发"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"Web开发"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"人工智能"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"爬虫"}),(n2:knowledge{name:"网络"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"爬虫"}),(n2:knowledge{name:"HTML"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"爬虫"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"HTML"}),(n2:knowledge{name:"Xpath"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"HTML"}),(n2:knowledge{name:"CSS"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"Windows办公软件"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"所属行业的业务知识"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"统计"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"统计"}),(n2:knowledge{name:"高数"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"统计"}),(n2:knowledge{name:"机器学习"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"人工智能"}),(n2:knowledge{name:"高数"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"机器学习"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"机器学习"}),(n2:knowledge{name:"深度学习"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"视觉"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"NLP"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"语音"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"推荐"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"大数据"}),(n2:direction{name:"离线计算"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"大数据"}),(n2:direction{name:"实时计算"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"Hive"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"HBase"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"Scala"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"Hadoop"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Scala"}),(n2:knowledge{name:"Spark"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"实时计算"}),(n2:knowledge{name:"JAVA"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"Hadoop"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"Flink"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"flume"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"kafka"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"Storm"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
5.查询关系:MATCH p=()-[r:relationship]->() RETURN p LIMIT 60