暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

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

左羊公社 2020-02-24
324

每日金句

人啊,根据重新振作的方法,大概可以分为两种:一种是看着比自己卑微的东西,找寻垫底的借以自慰;另一种是看着比自己伟大的东西,狠狠地踢醒毫无气度的自己。(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 V
          create class Occupation extends V
          create class camp extends V
          create class ascription extends E
          create 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="司马懿",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="司马懿") 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="司马懿") 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

          ]


          关注左羊公社

          发现更多精彩    



          文章转载自左羊公社,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

          评论