Referential integrity - Unique names (Northwind Data set)

Looking at this data set, I was thinking about how to best change the name of a product that a customer purchases such as the following:

match (p:Product{productName: "Chai"})
return p

Lets say 100 customers purchased the Chai. All customers would have the same relationship to the same node, correct?


As always, that depends on how exactly you modeled it :-), but lets assume that there are Customer nodes and Product nodes and the relationship-type is PURCHASED, then each (of your 100) specific Customer node would have one or more (see below for example) specific PURCHASED relationships (same type, not the same relationship !) to the Product node representing Chai yes ...

(:Customer {name: "Tom"})-[:PURCHASED {quantity: 5, date: 2017/09/23}]->(:Product {name: "Chai"})
(:Customer {name: "Tom"})-[:PURCHASED {quantity: 10, date: 2017/10/28}]->(:Product {name: "Chai"})
(:Customer {name: "Bill"})-[:PURCHASED {quantity: 7, date: 2018/01/05}]->(:Product {name: "Chai"})

Each PURCHASED relationship represents one ... purchase.
Does that make sense ? In this case changing the name of the product would merely mean updating the Product node for it.

Hope this helps.


Hi Tom,

Thank you for your response. I am using the Northwind dataset provided by Neo4j here. I'm trying to understand if I would need up update all nodes where the product name is Chai to Tea or only one node.


Also, are there any educational materials for teachers and so fourth? Especially with the Northwind dataset and recommendations?


If there's a unique constraint on the Product (label) name (property) combination there will be just one of those. In my example, there is one Customer node for Tom, one Product node for Chai, three relationships representing the purchases. Exactly as there would be in reality :-).