Mixed types inside a class. Is a good idea?

Skip to first unread message

Luis C.

Jul 28, 2015, 11:37:40 AM7/28/15
to OrientDB
Hi at all

I'm working with OrientDB on my project. I'm excited to use a multimodel db and I want to tries new ways for my work. Now I want to understand is a good choice to put mixed types inside a class. For example, in my project I have:

  • Class A
    • Prop A String
    • Prop B String
    • Prop C CustomClass<V>
    • Prop D CustomClass<V>
  • Class CustomClass<V>
    • Prop A String
    • Prop B link CustomAnotherClass (Document)
  • Class CustomAnotherClass 
    • Prop A String
    • Prob B String
What kind of problem can I have in the future? Performance problem? 

I use this configuration because in my mind I'm convinced that is preferable to do not use many property inside a Vertex. Is it only in my mind or there is a little truth? :)

Thanks for all


Luigi Dell'Aquila

Jul 29, 2015, 2:50:52 AM7/29/15
to orient-...@googlegroups.com
Hi Luigi,

it depends a lot on your use case. Fetching a big record is more expensive than fetching a small one, so if you access only a few properties very often, but you have many other properties that are never accessed, then having a linked object containing these other properties will give you some advantages.
On the other side, fetching two documents is more expensive than fetching a big one, so if you often need all the properties, having a single object that contains all will give you some advantage.
My advice is to design your domain model in a clear way (it will make things easier at development stage) and to do some tuning based on the use case



You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis C.

Jul 29, 2015, 3:52:01 AM7/29/15
to OrientDB, luigi.de...@gmail.com
Now the last thing that I need to understand is this: If I have this domain model, how can I interact with this.. For example. I fetch an ODocument Class A. I'll take the startNode (is a class that extend V) and I want to traverse it, like a graph. I need to open a new connection like graph db?

Luigi Dell'Aquila

Jul 29, 2015, 5:42:41 AM7/29/15
to Luis C., OrientDB
Hi Luis,

you can interact with your model in many ways, what I suggest you is to use an OrientGraph instance
OrientGraph g = new OrientGraph("dbUrl", "username", password");


Iterable<Vertex> iterable = g.command(new OCommandSQL("your select statement")).execute();

this way you will have Vertex instances ready to be used.
Vertex and Edge classes have all the API methods for application level traversal.

You can also use ODatabaseDocumentTx and then wrap documents with vertices (eg. g.getVertex(doc)) but it does not make sense in many cases



Reply all
Reply to author
0 new messages