Designing binary operations(AND, OR, NOT) in graphs DB's like neo4j

Posted by Nicholas on Programmers See other posts from Programmers or by Nicholas
Published on 2012-06-13T06:09:59Z Indexed on 2012/06/13 10:47 UTC
Read the original article Hit count: 389

Filed under:
|
|

I'm trying to create a recipe website using a graph database, specifically neo4j using spring-data-neo4j, to try and see what can be done in Graph Databases.

My model so far is:

(Chef)-[HAS_INGREDIENT]->(Ingredient)
(Chef)-[HAS_VALUE]->(Value)
(Ingredient)-[HAS_INGREDIENT_VALUE]->(Value)
(Recipe)-[REQUIRES_INGREDIENT]->(Ingredient)
(Recipe)-[REQUIRES_VALUE]->(Value)

I have this set up so I can do things like have the "chef" enter ingredients they have on hand, and suggest recipes, as well as suggest recipes that are close matches, but missing one ingredient.

Some recipes can get complex, utilizing AND, OR, and NOT type logic, something like (Milk AND (Butter OR spread OR (vegetable oil OR olive oil))) and I'm wondering if it would be sane to model this in a graph using a tree type representation?

An example of what I was thinking is to create three "node" types of AND, OR, and NOT and have each of them connect to the nodes value underneath.

How else might this be represented in a Graph Database or is my example above a decent representation?

© Programmers or respective owner

Related posts about binary

Related posts about boolean