If my model defines the measurementDate is located in the HAS relationship, is it feasible to transverse the graph to retrieve all measures from a group of patients ordered by patientId and measurementDate? Or extract all nodes from a range of dates?
This is a classic example of a MxN relationship in a relational database and, in this case, I would model the measurementDate field in the MxN table.
Is this approach correct?
2nd.) Person and Patient nodes share lots of information and Patient node is a derivation from Person node - you must be a Person before being a Patient. In the image, I have a Person (node) who is responsible for a Patient (node) like a mother is responsible for her child, the Patient is also Person
Should I replicate all shared attributes for both nodes or the attributes are automatically inherited from Person to Patient somehow? Does it make sense?
I'm fairly new to neo4j but I think I can offer some help.
The relationships between nodes are first class citizens, meaning they are just as important as the nodes. So you could think of your MxN join table as the HAS relationship and add the measurementDate attribute to the relationship HAS.
Traversing the graph to retrieve all measure from a group of patients and ordered by patientId and measurementDate is certainly feasible in this way. You would need to decide what format to save the measurementDate in however.
MATCH (p:Patient)-[rel:HAS]->(m:Measure) WHERE p.patientId IN [12,14,16] RETURN (p)-[rel]->(m) ORDER BY p.patientId, rel.measurementDate
Attributes are not inherited between nodes. I would say however, to treat them as separate entities and keep only Patient related attributes, in the Patient node, and any Person attributes only in the Person node.
Optionally you could actually treat them as a single node with two labels. So if a Person was also a Patient, you would just use one node with two labels. (p:Person:Patient)
No problem. One thing that I have found is you can easily adjust your graph model depending on your needs. You could also deploy a test graph you can chop and change until it fits your needs (i.e. queries you want to run against it).
I think there's a potential problem with time measurement.
In principle a patient is always a person, or rather being a patient is the temporary state of a person. At least I would insert in the Patient node the start and end date of the state.