在CMDB中有2個核心概念:
實體
關(guān)系
為了靈活管理多個實體浑塞,對實體引入了實體組的概念。
-- 建立 頂點 Group
CREATE CLASS Group EXTENDS V;
-- 建立 頂點 Enity
CREATE CLASS Enity EXTENDS V;
--- 建立 邊 Relation
CREATE CLASS Relation EXTENDS E;
-- 建立名為“運維資產(chǎn)”的實體組
CREATE VERTEX Group SET name="運維資產(chǎn)";
-- 建立名為“物理機”的實體
CREATE VERTEX Enity SET name="物理機";
-- 建立名為“機架”的實體
CREATE VERTEX Enity SET name="機架";
-- 建立關(guān)系 Contain
CREATE CLASS Contain EXTENDS Relation;
-- 建立關(guān)系 Lay
CREATE CLASS Lay EXTENDS Relation;
-- 建立關(guān)系 RelayOn
CREATE CLASS RelayOn EXTENDS Relation;
-- # contain, lay 直接基于Relation政己,看起來行不通酌壕。
-- CREATE EDGE Relation SET name="屬于";
-- CREATE EDGE Relation SET name="放置在";
CREATE EDGE Contain FROM (select from Group where name='運維資產(chǎn)' ) TO ( select from Enity where name='物理機' );
CREATE EDGE Contain FROM (select from Group where name='運維資產(chǎn)' ) TO ( select from Enity where name='機架' );
CREATE EDGE Lay FROM (select from Enity where name='物理機' ) TO ( select from Enity where name='機架' );
-- A實體 和 A實體 無法建立關(guān)系。
CREATE EDGE RelayOn FROM (select from Enity where name='物理機' ) TO ( select from Enity where name='物理機' );
-- 實體A 和 實體B 之間可以有多種關(guān)系匹颤;
CREATE EDGE RelayOn FROM (select from Enity where name='物理機' ) TO ( select from Enity where name='機架' );
-- 可以建立兩個 名為“物理機”的實體A,然后就可以建立關(guān)系
CREATE VERTEX Enity SET name="物理機";
CREATE EDGE RelayOn FROM (select from Enity where name='物理機' ) TO ( select from Enity where name='物理機' );
擴展閱讀:
==== 抽象
CREATE CLASS Group EXTENDS V;
CREATE CLASS Enity EXTENDS V;
CREATE CLASS Relation EXTENDS E;
CREATE CLASS Rack EXTENDS Enity;
CREATE CLASS PhysicalMachine EXTENDS Enity;
CREATE CLASS Contain EXTENDS Relation;
CREATE CLASS Lay EXTENDS Relation;
CREATE EDGE Lover FROM (select from Preson where name='小朱') TO (select from Preson where name='小劉');
----
-- CREATE CLASS Relay EXTENDS E;
-- CREATE CLASS Contain EXTENDS E;
CREATE VERTEX Group SET name="運維資產(chǎn)";
CREATE VERTEX Enity SET name="物理機";
CREATE VERTEX Enity SET name="機架";
CREATE VERTEX Relation SET name="屬于";
CREATE VERTEX Relation SET name="放置在";