Changing multiple parts of a triple simultaneously - good practice?

As a newbie and coming from decades of SQL querying of relational databases, I was pleasantly surprised to find I can do:
//Damage the information (for table 'Trucking'
MATCH (t:DBTable {name:'Trucking'})-[r:COMPOSITION_LINK_t]->(d:Datastore)
SET t.datastoreName='Bad DB Name', r.originName = 'Bad origin Name',d.caption='Bad Caption'

As will be seen, I changed the origin node, the relationship and the destination node in one action. IIRC, correctly, this type of thing is NOT possible in the Relational Model; you can only change one thing t a time.

I just wanted to check that this is good (not necessarily best) practice.

TIA,
PAolo

Yes, definitely something you can do! Basically you are free to bind any piece of a graph pattern (node, relationship, path etc) to a variable and manipulate the node/relationship property values throughout the Cypher query.

Not sure about best practices around this, but something I do pretty regularly - especially around data import or loading additional data.

Thanks, William @lyonwj ,
Good to know!

Paolo

1 Like