3

I am planning to use Neo4j to handle a database that I'm interested in creating.

I have not settled on the data model that I will use to represent my domain, but lets assume a model for the database that has Evaluator and State nodes with an as yet undefined relationship between them. What I need the database to do is as follows...

FUNCTION 1 Each Evaluator can have result that can be above or below a base range. For a given Evaluator (E1), if the result is above the base range (BR), there is a relationship to State S1. if the result is within the base range (BR), there is no relationship to any State. if the result is below the base range (BR), there is a relationship to State S2. Hence an Evaluator might have two properties: result and base range. Base range could be represented as Base range Hi and Base range low for easy calculation.

Lets say a user inputs a result for a given Evaluator; I would like that input to invoke an automatic query that depends upon the value of the result in relation to the base range. That query would return all the states related to an evaluator with a given result value. The key idea here is a conditional relationship depending upon the value of user input. I'm sure there are other ways to do this (relationship property?), but the same idea of a conditional relationship based on user input is of interest to me.

CAN FUNCTION 1 BE DONE?

FUNCTION 2 Then lets say that there are 2 evaluators E1 and E2. Lets say that various combinations of Evaluators with values above or below their distinct base ranges have conditional relationships to S1, S2…Sn

        E1 High, E2 low; relationship with S1
        E1 High E2  BR; relationship with S2
        E1 High, E2 High; relationship with S3
        E1 BR,  E2 High; relationship with S4
        E1 low, E2 High; relationship with S5
        E1 BR, E2 BR; no relationship to a State

Lets say a user inputs a value for results for E1 and E2. I would like that combination to invoke an automatic query that also depends upon the value of the results in relation to the base ranges. That query would return all the states related to E1 and E2 with a given result values. The key idea here is a combinatorial conditional relationship depending upon the value of user input.

CAN FUNCTION 2 BE DONE?

David Makogon
  • 69,407
  • 21
  • 141
  • 189

1 Answers1

0

This question really seems oriented toward your app domain logic, not about Neo4j itself. With Neo4j, it's entirely possible to dynamically add/remove nodes, add/remove relationships, etc. For function 1, you'd just need to add or remove the relationship between E1 and S1/S2 (via your app logic; there's no automatic conditional-relationship mechanism to rely upon). And for function 2, again you'd add or remove a relationship between E1/E2 and S1-S5 (or just leave E1 & E2 without any relationship).

You'll be able to do any of the query+add or query+remove via Cypher (latest documentation is here).

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • Thanks David! Yes, I have read that data model design should be based on the kind of queries that you want to perform. I have tried to pin down the exact queries I will need to perform without knowing clearly how it will be implemented. I suppose my questions addresses how closely Neo4J capabilities will map to my domain logic. – Jose Morales Aug 25 '13 at 12:40
  • Pardon my ignorance David, but would your suggestion mean that when a user makes a query, then they alter the database by adding or removing relationships? – Jose Morales Aug 25 '13 at 13:28
  • No - you'd have to update your relationships whenever you update the properties in your nodes. Read-only queries should be idempotent. You should not update your database on a read query. – David Makogon Aug 25 '13 at 13:50
  • Yes, this sounds right..."read-only queries"...the point of the whole operation is to give users access to the E-S relationship information encoded in the database. The only thing that should vary are the actual results with the three options being above, below or within the base range. – Jose Morales Aug 25 '13 at 19:14
  • @DavidMakogon, Function 1 is what I'm struggling with. would you take at look at this? http://stackoverflow.com/questions/29611239/how-to-create-conditional-relationships – ekkis Apr 13 '15 at 17:42