Assuring a Label's "integrity"
I am looking for a Best Practice to solve the follwing case:
Assume I have a graph with student nodes, each with the ususal attributes (name,birth date,gender,height...).
Some of the students have an attribute "plays", which has the value of the musical instrument (Assume ONE) he/she plays.
I add a Label "Musician" by running
match (a: Student) where a.plays <> "" set a:Musician
Now I can perform queries on musicians only:
match (a:Musician) return avg(a.height)
Nice and good - at the point in time this statement is run.
Assume a non-musician took up an instrument, or a new student comes to school - a Node should be either added or upadated.
I will have to assure the test for "plays", and the validity of the "Musician" label, is done.
How can I GUARANTEE it?
I can have an adminstrative rule that updates are done only through a single procedure - but then I may be at the mercy of the worst "I am in a hurry" privileged user.
What can I do so the modification/update ALWAYS performs the test (in SQL, you would do that with a Trigger) ?
I S R A E L