Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional Relationship in Graph DB

How would a graph model handle a conditional relationship like:

(Alice -[Dates]-> Bob)  
Where [Dates] exists IF and ONLY IF 
(Bob -[Owns]-> Ferrari) is true

Besides just querying, I'm wondering whether the relationship be applied by the database engine based on the condition or whether this needs to be managed in the application.

like image 721
Jonathon Anderson Avatar asked Jan 09 '23 15:01

Jonathon Anderson


1 Answers

The answer of FrobberOfBits is very good and holds true for the ArangoDB database as well. However ArangoDB offers a micro-service framework called "Foxx" that allows you to define additional API endpoints for your database that can execute custom code.

One application for Foxx would exactly be your problem: * Define an endpoint to remove the relation that does two things: 1) Delete the relation 2) Check for all logical constraints or side-effects and apply them

This gives you the advantage that is executed directly in the database (only one query-trigger) and your application code is free of these constraints.

like image 175
mchacki Avatar answered Feb 09 '23 20:02

mchacki