简体   繁体   English

Orientdb SQL查询以检查边缘属性

[英]Orientdb SQL query to check edge properties

I have a Graph database with three simple Vertex types, User, Device and Sensor. 我有一个具有三个简单顶点类型(用户,设备和传感器)的Graph数据库。 The relationship goes as, 关系是这样的,

Edges: UserHasDevices, DeviceHasSensors 边缘:UserHasDevices,DeviceHasSensors

Each edge has a property name "isDeleted". 每个边都有一个属性名称“ isDeleted”。 When deleting a Vertex, I don't make it deleted permanently but make the "isDeleted" property of the Edge as "true". 删除顶点时,我不会使它永久删除,而是将Edge的“ isDeleted”属性设为“ true”。 Please let me know How to query a list of deleted sensors, and / or deleted list of devices, which belongs to a particular user, identified by user id. 请让我知道如何查询属于特定用户的,由用户ID标识的已删除传感器的列表和/或已删除设备的列表。

To filter by edges property, you can use outE('edgeName') and put your conditions in some brackets. 要按edges属性过滤,可以使用outE('edgeName')并将条件放在方括号中。 This is supposed to work according to my understanding : 根据我的理解,这应该可以工作:

select expand(outE('UserHasDevices')[isDeleted = true].inV()) from #13:12

In another question , the asker says it doesn't work. 在另一个问题中 ,询问者说它不起作用。

I found another way to do this. 我找到了另一种方法。 You can also expand from the edges. 您也可以从边缘扩展。 This would look like this : 看起来像这样:

select expand(in) from UserHasDevices where isDeleted = true and out = #13:12

But I don't think it is the best ideal to store a property in an edge performance wise. 但我认为以最佳性能存储属性不是最好的选择。 The best thing to do would be to have another edge that contains the "isDeleted" vertices. 最好的做法是让另一个包含“ isDeleted”顶点的边。 It would be simpler and it would allow you to have a smaller query execution time. 这样会更简单,并且可以缩短查询执行时间。 This would eliminate the need to filter by the edge property. 这将消除对edge属性进行过滤的需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM