赞
踩
以西游记小说为为例子
创建取经团队的人物,包含名称和年龄属性
CREATE (xyj_tsz:X_Person{name:"唐三藏",age:39})
CREATE (xyj_swk:X_Person{name:"孙悟空",age:520})
CREATE (xyj_zbj:X_Person{name:"猪八戒",age:512})
CREATE (xyj_swj:X_Person{name:"沙悟净",age:444})
创建团队人物之间的关系,师傅和师兄弟
MATCH (a:X_Person),(b:X_Person)
WHERE a.name = '唐三藏' AND (b.name = '猪八戒' or b.name ='沙悟净')
CREATE (a)-[r:师傅] -> (b)
RETURN r
MATCH (a:X_Person),(b:X_Person)
WHERE a.name = '孙悟空' AND (b.name = '猪八戒' or b.name ='沙悟净')
CREATE (a)-[r:师兄] -> (b)
RETURN r
MATCH (a:X_Person),(b:X_Person)
WHERE a.name = '猪八戒' AND (b.name ='沙悟净')
CREATE (a)-[r:师兄] -> (b)
RETURN r
CREATE (xyj_wuqi:X_Wuqi{name:"金箍棒",age:10000})
CREATE (xyj_wuqi:X_Wuqi{name:"九齿钉耙",age:2000})
CREATE (xyj_wuqi:X_Wuqi{name:"禅杖",age:50000})
match (a: X_Person),(b:X_Wuqi)
where a.name = '孙悟空' and b.name = '金箍棒'
create (a) -[r: has] -> (b)
return r;
match (a: X_Person),(b:X_Wuqi)
where a.name = '沙悟净' and b.name = '禅杖'
create (a) -[r: has] -> (b)
return r;
match (a: X_Person),(b:X_Wuqi)
where a.name = '猪八戒' and b.name = '九齿钉耙'
create (a) -[r: has] -> (b)
return r;
match (a:X_Person) -[r:has] ->(b:X_Wuqi) return a,b
match (a:X_Person) -[r:has] ->(b:X_Wuqi) where a.name = '孙悟空' return a,b
创建道教和佛教
CREATE (xyj_DaoTong:X_DaoTong{name:"佛教",age:9999999})
CREATE (xyj_DaoTong:X_DaoTong{name:"道教",age:9999999})
创建佛教几个角色
CREATE (xyj_Fo:X_Fo{name:"如来佛祖",age:9999999})
CREATE (xyj_Fo:X_Fo{name:"观音菩萨",age:99999})
CREATE (xyj_Fo:X_Fo{name:"观音菩萨",age:99999})
CREATE (xyj_Fo:X_Fo{name:"普贤菩萨",age:99999})
CREATE (xyj_Fo:X_Fo{name:"孔雀明王",age:99999})
创建佛教的角色属于佛教的关系
match (a: X_Fo),(b:X_DaoTong)
where b.name ='佛教'
create (a) -[r: belong_to] -> (b)
return r;
同样创建道教任务和角色,建立关系
根据创建节点和关系,创建了下面的所有实体和关系。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。