代码之家  ›  专栏  ›  技术社区  ›  Hristo Stoyanov

边指向边?

  •  1
  • Hristo Stoyanov  · 技术社区  · 7 年前

    在OrientDB 3.0.x(x>5)中,是否可能有一条边,其一端也是边?这似乎是可能的,但文件中没有解释:

            --Define vertex A,B,C
            create class testVertexA extends V;
            create class testVertexB extends V;
            create class testVertexC extends V;
    
            --Define EdgeA that connects 2 vertexes -A and B
            create class testEdgeA extends E;
            create property testEdgeA.in link testVertexA;
            create property testEdgeA.out link testVertexB;
    
            --Define EdgeB that connects EdgeA and vertex C - is this possible?
            create class testEdgeB extends E;
            create property testEdgeB.in link testVertexC;
            create property testEdgeB.out link testEdgeA;
    

    接下来,我们输入一些数据,看看这是否有效: orientdb>插入testVertexA;

    Inserted record '[testVertexA#225:0 v1]' in 0.000000 sec(s).
    
    orientdb > insert into testVertexB;
    
    Inserted record '[testVertexB#233:0 v1]' in 0.016000 sec(s).
    
    orientdb > insert into testVertexC;
    
    Inserted record '[testVertexC#241:0 v1]' in 0.000000 sec(s).
    
    orientdb > insert into testEdgeA set in=#225:0, out=#233:0;
    
    Inserted record '[testEdgeA#249:0{in:#225:0,out:#233:0} v1]' in 0.000000 sec(s).
    
    orientdb > insert into testEdgeB set in=#241:0, out=#249:0;
    
    Inserted record '[testEdgeB#257:0{in:#241:0,out:#249:0} v1]' in 0.000000 sec(s).
    
    orientdb > select from testEdgeB;
    
    +----+------+---------+------+------+
    |#   |@RID  |@CLASS   |in    |out   |
    +----+------+---------+------+------+
    |0   |#257:0|testEdgeB|#241:0|#249:0|
    +----+------+---------+------+------+
    
    1 item(s) found. Query executed in 0.0 sec(s).
    
    orientdb > select from  #241:0
    
    +----+------+-----------+
    |#   |@RID  |@CLASS     |
    +----+------+-----------+
    |0   |#241:0|testVertexC|
    +----+------+-----------+
    
    1 item(s) found. Query executed in 0.0 sec(s).
    orientdb > select from  #249:0
    
    +----+------+---------+------+------+
    |#   |@RID  |@CLASS   |in    |out   |
    +----+------+---------+------+------+
    |0   |#249:0|testEdgeA|#225:0|#233:0|
    +----+------+---------+------+------+
    
    1 item(s) found. Query executed in 0.0 sec(s).
    

    有人能肯定这一点吗。谢谢

    0 回复  |  直到 7 年前