Sunday, November 6, 2016

Solving lack of existence constraints in Neo4j Community Edition with OrientDB graph database

Sometime when creating nodes or relationships it's useful to define some mandatory properties (or existence constraints).

In other words, you may want to force that a specific property requires a value for all nodes or all relationships.

One way to do this is by creating an existence constraint, or by requiring that the property is mandatory during property creation (or modification).

While Neo4j Enterprise Edition supports property existence constraints, they are not supported in the Neo4's Community Edition. Furthermore, databases that are created with the Enterprise Edition and that include property existence constraints cannot be opened using Neo4j Community Edition.

On the other hand, OrientDB does support mandatory properties - even in the Community Edition!

With OrientDB you can easily create a property with a mandatory attribute. You can also edit an already existent property to require that it is a mandatory one.

Using Studio, the web interface for the administration of OrientDB that comes bundled with the OrientDB distribution, you can create or edit a mandatory property following these steps:
  1. Click on "Schema" from the top level menus
  2. Click on the Vertex or Edge class where you want to create or edit the mandatory property
    • To create a new mandatory property, click on the "New Property" button and select the mandatory flag when the property creation window appears
    • To edit an existent property to require that it is a mandatory one, identify the property within the list of all available properties, and click on the "mandatory" flag
Creating a mandatory property in OrientDB Community Edition
Editing an existent property to require the "mandatory" attribute in OrientDB's Community Edition

If instead of Studio you want to use OrientDB's SQL, you can use the CREATE PROPERTY or ALTER PROPERTY commands.

If you want to have mandatory properties (or existence constraints) in your graph and you want to avoid the cost (*) associated with Neo4j Enterprise Edition, you can consider OrientDB, the open-source distributed Graph / Document Multi-Model Database, where mandatory properties are supported and included in the Community Edition.


(*) According to Gartner, Neo Technology "received among the lowest scores in the reference customer survey for value and for pricing model; cost was a key reason cited for not choosing this vendor when it was under consideration." - Magic Quadrant for Operational Database Management Systems, 05 October 2016

All trademarks are the property of their respective owners.

No comments:

Post a Comment