OrientDB之图解Web后台使用(一)

2022-04-14 00:00:00 魏国 蜀国 长安 法师 坦克

每日金句

人啊,根据重新振作的方法,大概可以分为两种:一种是看着比自己卑微的东西,找寻垫底的借以自我安慰;另一种是看着比自己伟大的东西,狠狠地踢醒毫无气度的自己。(by 银魂)


今天左羊带领大家以模拟战(MockWarfare)为例,讲解如何使用OrientDB的Web后台!

 

思路讲解:大家大部分因该都玩过荣耀中的模拟战,玩过因该都知道他是有英雄,阵营,职业,天赋组成的,也就是说他们之间或多或少都有关联性,今天左羊就带领大家使用OrientDB图数据库的Web后台绘出它们之间的关系图谱。好了,废话少说,走起!

类/关系梳理(示例关系梳理)V 顶点person(英雄)Occupation(职业)camp(阵营)
E 边缘:ascription(归属),job(职业)

英雄是由也阵营和职业两种羁绊,今天我们以此为例绘出英雄归属什么阵营从事什么职业的关系图谱。

 

创建数据库

首先我们启动OrientDB服务

当我们启动完服务后,可以去浏览器索引框输入 localhost:2480进入WEB后台登录页

在这个页面我们可以看到如下内容

Database 数据库 我们可以在选项后面的下拉框中选取想要登录的数据库User ,用户 默认root,当然你也可以自己指定一个,这个我们日后再说password 密码 在你次执行server.sh.bat时会提示你创建的密码connect 连接NEW DB 创建新的数据库那个垃圾桶图标是删除当前显示的数据库那个云图标左羊还没搞明白,大概是从某处获取数据库吧

让我们创建一个名为MockWarfare的数据库吧!

点击新建

点击确认后我们会直接点转到如下界面

创建实体类(大致相当于NavCat的建表)

V 顶点person(英雄)Occupation(职业)camp(阵营)E 边缘:,ascription(归属),job(职业)

双击NEW VERTEX或NEW EDGE

输入name,点击save。接下来我们把所有的顶点和边创建出来。

接下我们使用它内置的SQL执行器插入数据

然后我们在通过点击方式添加数据

接下我们将所有的顶点插入进去

接下我们使用图形编辑器进行边缘关系的绘制


 以下是本文涉及到的全部SQL语句

创建数据库create database remote:localhost/MockWarfare root root连接数据库connect remote:localhost/MockWarfare root root创建实体类create class Person extends Vcreate class Occupation extends Vcreate class camp extends Vcreate class ascription extends Ecreate class job extends E创建Vertex阵营实体create vertex camp set name="吴国"create vertex camp set name="蜀国"create vertex camp set name="魏国"create vertex camp set name="尧天"create vertex camp set name="稷下"create vertex camp set name="扶桑"create vertex camp set name="长城守卫军"create vertex camp set name="长安"create vertex camp set name="群雄"create vertex camp set name="封神"职业实体create vertex Occupation set name="战士",title="物理伤害"create vertex Occupation set name="射手",title="物理伤害"create vertex Occupation set name="法师",title="法术伤害"create vertex Occupation set name="刺客",title="物理伤害"create vertex Occupation set name="坦克",title="抗揍"create vertex Occupation set name="法辅",title="抗揍"create vertex Occupation set name="肉辅",title="抗揍"英雄实体create vertex Person set name="吕布",camp="群雄",Occupation="战士"create vertex Person set name="曹操",camp="魏国",Occupation="战士"create vertex Person set name="典韦",camp="魏国",Occupation="战士"create vertex Person set name="宫本武藏",camp="扶桑",Occupation="战士"create vertex Person set name="老夫子",camp="稷下",Occupation="战士"create vertex Person set name="花木兰",camp="长城守卫军",Occupation="战士"create vertex Person set name="橘右京",camp="扶桑",Occupation="战士"create vertex Person set name="刘备",camp="蜀国",Occupation="战士"create vertex Person set name="李信",camp="长城守卫军",Occupation="战士"create vertex Person set name="孙尚香",camp="吴国",Occupation="射手"create vertex Person set name="狄仁杰",camp="长安",Occupation="射手"create vertex Person set name="李元芳",camp="长安",Occupation="射手"create vertex Person set name="黄忠",camp="蜀国",Occupation="射手"create vertex Person set name="百里守约",camp="长城守卫军",Occupation="射手"create vertex Person set name="公孙离",camp="尧天",Occupation="射手"create vertex Person set name="伽罗",camp="长城守卫军",Occupation="射手"create vertex Person set name="鲁班七号",camp="稷下",Occupation="射手"create vertex Person set name="后羿",camp="封神",Occupation="射手"create vertex Person set name="小乔",camp="吴国",Occupation="法师"create vertex Person set name="墨子",camp="稷下",Occupation="法师"create vertex Person set name="周瑜",camp="吴国",Occupation="法师"create vertex Person set name="甄姬",camp="魏国",Occupation="法师"create vertex Person set name="武则天",camp="长安",Occupation="法师"create vertex Person set name="貂蝉",camp="群雄",Occupation="法师"create vertex Person set name="不知火舞",camp="扶桑",Occupation="法师"create vertex Person set name="诸葛亮",camp="蜀国",Occupation="法师"create vertex Person set name="弈星",camp="尧天",Occupation="法师"create vertex Person set name="沈梦溪",camp="长城守卫军",Occupation="法师"create vertex Person set name="赵云",camp="蜀国",Occupation="刺客"create vertex Person set name="元歌",camp="蜀国",Occupation="刺客"create vertex Person set name="李白",camp="长安",Occupation="刺客"create vertex Person set name="司ma懿",camp="魏国",Occupation="刺客"create vertex Person set name="娜可露露",camp="扶桑",Occupation="刺客"create vertex Person set name="百里玄策",camp="长城守卫军",Occupation="刺客"create vertex Person set name="裴擒虎",camp="尧天",Occupation="刺客"create vertex Person set name="上官婉儿",camp="长安",Occupation="刺客"create vertex Person set name="廉颇",camp="稷下",Occupation="坦克"create vertex Person set name="刘禅",camp="蜀国",Occupation="坦克"create vertex Person set name="钟无艳",camp="稷下",Occupation="坦克"create vertex Person set name="夏侯惇",camp="魏国",Occupation="坦克"create vertex Person set name="程咬金",camp="长安",Occupation="坦克"create vertex Person set name="钟馗",camp="长安",Occupation="坦克"create vertex Person set name="苏烈",camp="长城守卫军",Occupation="坦克"create vertex Person set name="孙策",camp="吴国",Occupation="坦克"create vertex Person set name="嫦娥",camp="封神",Occupation="坦克"create vertex Person set name="蔡文姬",camp="魏国",Occupation="法辅"create vertex Person set name="大乔",camp="吴国",Occupation="法辅"create vertex Person set name="孙膑",camp="稷下",Occupation="法辅"create vertex Person set name="姜子牙",camp="封神",Occupation="法辅"create vertex Person set name="杨玉环",camp="尧天",Occupation="法辅"create vertex Person set name="明世隐",camp="尧天",Occupation="肉辅"create vertex Person set name="太乙真人",camp="封神",Occupation="肉辅"create vertex Person set name="张飞",camp="蜀国",Occupation="肉辅"create vertex Person set name="盾山",camp="长城守卫军",Occupation="肉辅"创建Edge归属关系实体ascription(归属)create edge ascription from(select from Person where name="吕布") to(select from camp where name="群雄")create edge ascription from(select from Person where name="曹操") to(select from camp where name="魏国")create edge ascription from(select from Person where name="典韦") to(select from camp where name="魏国")create edge ascription from(select from Person where name="宫本武藏") to(select from camp where name="扶桑")create edge ascription from(select from Person where name="老夫子") to(select from camp where name="稷下")create edge ascription from(select from Person where name="花木兰") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="橘右京") to(select from camp where name="扶桑")create edge ascription from(select from Person where name="刘备") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="李信") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="孙尚香") to(select from camp where name="吴国")create edge ascription from(select from Person where name="狄仁杰") to(select from camp where name="长安")create edge ascription from(select from Person where name="李元芳") to(select from camp where name="长安")create edge ascription from(select from Person where name="黄忠") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="百里守约") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="公孙离") to(select from camp where name="尧天")create edge ascription from(select from Person where name="伽罗") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="鲁班七号") to(select from camp where name="稷下")create edge ascription from(select from Person where name="后羿") to(select from camp where name="封神")create edge ascription from(select from Person where name="小乔") to(select from camp where name="吴国")create edge ascription from(select from Person where name="墨子") to(select from camp where name="稷下")create edge ascription from(select from Person where name="周瑜") to(select from camp where name="吴国")create edge ascription from(select from Person where name="甄姬") to(select from camp where name="魏国")create edge ascription from(select from Person where name="武则天") to(select from camp where name="长安")create edge ascription from(select from Person where name="貂蝉") to(select from camp where name="群雄")create edge ascription from(select from Person where name="不知火舞") to(select from camp where name="扶桑")create edge ascription from(select from Person where name="诸葛亮") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="弈星") to(select from camp where name="尧天")create edge ascription from(select from Person where name="沈梦溪") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="赵云") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="元歌") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="李白") to(select from camp where name="长安")create edge ascription from(select from Person where name="司ma懿") to(select from camp where name="魏国")create edge ascription from(select from Person where name="娜可露露") to(select from camp where name="扶桑")create edge ascription from(select from Person where name="百里玄策") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="裴擒虎") to(select from camp where name="尧天")create edge ascription from(select from Person where name="上官婉儿") to(select from camp where name="长安")create edge ascription from(select from Person where name="廉颇") to(select from camp where name="稷下")create edge ascription from(select from Person where name="刘禅") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="钟无艳") to(select from camp where name="稷下")create edge ascription from(select from Person where name="夏侯惇") to(select from camp where name="魏国")create edge ascription from(select from Person where name="程咬金") to(select from camp where name="长安")create edge ascription from(select from Person where name="钟馗") to(select from camp where name="长安")create edge ascription from(select from Person where name="苏烈") to(select from camp where name="长城守卫军")create edge ascription from(select from Person where name="孙策") to(select from camp where name="吴国")create edge ascription from(select from Person where name="嫦娥") to(select from camp where name="封神")create edge ascription from(select from Person where name="蔡文姬") to(select from camp where name="魏国")create edge ascription from(select from Person where name="大乔") to(select from camp where name="吴国")create edge ascription from(select from Person where name="孙膑") to(select from camp where name="稷下")create edge ascription from(select from Person where name="姜子牙") to(select from camp where name="封神")create edge ascription from(select from Person where name="杨玉环") to(select from camp where name="尧天")create edge ascription from(select from Person where name="明世隐") to(select from camp where name="尧天")create edge ascription from(select from Person where name="太乙真人") to(select from camp where name="封神")create edge ascription from(select from Person where name="张飞") to(select from camp where name="蜀国")create edge ascription from(select from Person where name="盾山") to(select from camp where name="长城守卫军")职业关系job(工作)create edge job from(select from Person where name="吕布") to(select from Occupation where name="战士")create edge job from(select from Person where name="曹操") to(select from Occupation where name="战士")create edge job from(select from Person where name="典韦") to(select from Occupation where name="战士")create edge job from(select from Person where name="宫本武藏") to(select from Occupation where name="战士")create edge job from(select from Person where name="老夫子") to(select from Occupation where name="战士")create edge job from(select from Person where name="花木兰") to(select from Occupation where name="战士")create edge job from(select from Person where name="橘右京") to(select from Occupation where name="战士")create edge job from(select from Person where name="刘备") to(select from Occupation where name="战士")create edge job from(select from Person where name="李信") to(select from Occupation where name="战士")create edge job from(select from Person where name="孙尚香") to(select from Occupation where name="射手")create edge job from(select from Person where name="狄仁杰") to(select from Occupation where name="射手")create edge job from(select from Person where name="李元芳") to(select from Occupation where name="射手")create edge job from(select from Person where name="黄忠") to(select from Occupation where name="射手")create edge job from(select from Person where name="百里守约") to(select from Occupation where name="射手")create edge job from(select from Person where name="公孙离") to(select from Occupation where name="射手")create edge job from(select from Person where name="伽罗") to(select from Occupation where name="射手")create edge job from(select from Person where name="鲁班七号") to(select from Occupation where name="射手")create edge job from(select from Person where name="后羿") to(select from Occupation where name="射手")create edge job from(select from Person where name="小乔") to(select from Occupation where name="法师")create edge job from(select from Person where name="墨子") to(select from Occupation where name="法师")create edge job from(select from Person where name="周瑜") to(select from Occupation where name="法师")create edge job from(select from Person where name="甄姬") to(select from Occupation where name="法师")create edge job from(select from Person where name="武则天") to(select from Occupation where name="法师")create edge job from(select from Person where name="貂蝉") to(select from Occupation where name="法师")create edge job from(select from Person where name="不知火舞") to(select from Occupation where name="法师")create edge job from(select from Person where name="诸葛亮") to(select from Occupation where name="法师")create edge job from(select from Person where name="弈星") to(select from Occupation where name="法师")create edge job from(select from Person where name="沈梦溪") to(select from Occupation where name="法师")create edge job from(select from Person where name="赵云") to(select from Occupation where name="刺客")create edge job from(select from Person where name="元歌") to(select from Occupation where name="刺客")create edge job from(select from Person where name="李白") to(select from Occupation where name="刺客")create edge job from(select from Person where name="司ma懿") to(select from Occupation where name="刺客")create edge job from(select from Person where name="娜可露露") to(select from Occupation where name="刺客")create edge job from(select from Person where name="百里玄策") to(select from Occupation where name="刺客")create edge job from(select from Person where name="裴擒虎") to(select from Occupation where name="刺客")create edge job from(select from Person where name="上官婉儿") to(select from Occupation where name="刺客")create edge job from(select from Person where name="廉颇") to(select from Occupation where name="坦克")create edge job from(select from Person where name="刘禅") to(select from Occupation where name="坦克")create edge job from(select from Person where name="钟无艳") to(select from Occupation where name="坦克")create edge job from(select from Person where name="夏侯惇") to(select from Occupation where name="坦克")create edge job from(select from Person where name="程咬金") to(select from Occupation where name="坦克")create edge job from(select from Person where name="钟馗") to(select from Occupation where name="坦克")create edge job from(select from Person where name="苏烈") to(select from Occupation where name="坦克")create edge job from(select from Person where name="孙策") to(select from Occupation where name="坦克")create edge job from(select from Person where name="嫦娥") to(select from Occupation where name="坦克")create edge job from(select from Person where name="蔡文姬") to(select from Occupation where name="法辅")create edge job from(select from Person where name="大乔") to(select from Occupation where name="法辅")create edge job from(select from Person where name="孙膑") to(select from Occupation where name="法辅")create edge job from(select from Person where name="姜子牙") to(select from Occupation where name="法辅")create edge job from(select from Person where name="杨玉环") to(select from Occupation where name="法辅")create edge job from(select from Person where name="明世隐") to(select from Occupation where name="肉辅")create edge job from(select from Person where name="太乙真人") to(select from Occupation where name="肉辅")create edge job from(select from Person where name="张飞") to(select from Occupation where name="肉辅")create edge job from(select from Person where name="盾山") to(select from Occupation where name="肉辅")

 成果展示

手敲了200多行SQL不行了,明天将给大家带来ETL数据导入操作,敬请期待吧!



[

END

]

来自:https://mp.weixin.qq.com/s/XLLmuUKGBsVzZQ8S7mxgAQ


相关文章