0

I am creating a PERT tool, and adapting this tutorial to my case.

What I want to do is forbidding the creation of relationships, and the creation of properties:

  1. The START node (which is an :EndPoint, not an :Activity) should not have predecessors, only successors

  2. The FINISH node (which is an :EndPoint, not an :Activity) should not have successors, only predecessors

  3. No CYCLE allowed

    • Each :Activity directly preceding by START cannot have other activities as predecessors
    • Each :Activity (in+)directly predecessor of a activities cannot have these activities as predecessors.

I have not found a way to block these relationships creations. The constraints do not seem to be what I want to do, the UNIQUENESS is not at all what I am looking for.

I tried to take the problem in an other way :

  1. Authorise only successors property for the START:EndPoint
  2. Authorise only predecessors property for the FINISH:EndPoint

but for the 3rd point, I have no idea, and the "reverse-thinking" could be a solution, but I did not find how to apply it.

If you have any idea, even not working, but giving a new vision, I would really appreciate.

BDL
  • 21,052
  • 22
  • 49
  • 55
  • "forbidding the creation of relationships, and the creation of properties" - I understand the relationships part, but what properties would you like to forbid? "Authorise only successors property for the START:EndPoint" - are you sure this is a property and not a relationship? – Gabor Szarnyas Sep 30 '17 at 15:03
  • Also, if both the start and the finish nodes are EndPoints, how do you tell the difference between them? – Gabor Szarnyas Sep 30 '17 at 15:05
  • ☼ Thank you Gabor for your questions. It's a web-based tool, and when the user creates a project, the two endpoints are created at the same time. The START:EndPoint as the properties {position:"Start", ES:0, EF:0, LS:0, LF:0, successors:[]} The FINISH:EndPoint as the properties {position:"Finish", ES:0, EF:0, LS:0, LF:0, predecessors:[]} In the arrays, the activities.names connected to these endpoints are stored for an HTML purpose, but I do not read the data inside the arrays for my queries. ES = Earliest Start EF = Earliest Finish LS = Latest Start LF = Latest Finish – Suraja Hathi Sep 30 '17 at 21:12

2 Answers2

1

Contrary to what is custom here I'm going to give an opinion. The reason being that you're actually not talking about restrictions at the level of the database (aka schema) but restrictions at the level of your problem (aka business rules).

There are lots of ways to implement business logic the main (and probably the best) one being ... in your application logic.

A Neo4j specific one would be to use user defined procedures. Not unlike the use of stored procedures and triggers that you might use to solve similar problems in an RDBMS such as Oracle.

Hope this helps.

Regards, Tom

Tom Geudens
  • 2,638
  • 9
  • 15
  • ☼ Thank you Tom for your time and your opinion ! It was the new vision I needed ! I will definitely work on it. Thank you again, Regards, Suraja – Suraja Hathi Sep 30 '17 at 22:31
1

You correctly concluded that using constraints is not the right approach here. While they are proposed to the openCypher language, this is an ongoing process and structural constraints are not supported by current implementations.

I agree with Tom Geudens' answer: you should prevent the creation of relationships that would violate your constraints in the application logic.

Gabor Szarnyas
  • 4,410
  • 3
  • 18
  • 42