Search code examples
graphgremlinorientdb

Nested records in orientDB and querying the same


I need to store a graph with vertices and edges.My use case is as follows:

Each vertex has following properties.

There are some basic properites like name , age etc and then there are some record kind of properties

Prop1 Prop2 Prop3 Prop4 Pro5
"xyz"  "1"   "2"  "ha"   7
"abc"  "1"  "3"   "aks" 8

Note:This are the properties only one vertex.These are kind of nested properties.Nested properties are kind of records in relational DB.

1)Now i want to fire SQL like queries on these nested properties /records.IS this possible? Eg Find for each vertex valueOf Prop5 only if Prop2="1" .These are kind of relational DB queries.

Eg2: count number of nested records with Prop5 value = 7

IS this supported in OrinetDB ?If yes how?


Solution

  • You can embed records inside records. If are multiple records to be embedded use an EMBEDDEDMAP, EMBEDDEDSET or EMBEDDEDLIST. To query it you could do something like:

    select Prop5 from blabla where embeddedProperties contains ( Prop2 = '1' )
    

    Assuming embeddedProperties it's a list of embedded records (EMBEDDEDLIST).