Scenario: a simple address book where a user can create his own contacts and organize them by adding them in groups. A contact may have multiple addresses.
I have created the following diagram: ![schema-design][1]
I want to query all the contacts who are placed in group x and live in country y.
Is this schema design good enough for those purposes (I want to use the neo4j database)?
It looks like the notion of
countryshould be a first class citizen in your graph since your query depends on it. Graph model design typically gets influenced a lot by your query patterns.So I suggest to have a node labeled
Countryfor each country and connect theAddressnode with:LOCATED_INrelationships to the country. (consequently drop the country property from the address nodes).With that change your query is as easy as: