Ensuring data integrity with 1:n connections in arangodb (delete orphan vertex automatically)

31 views
Skip to first unread message

do point

unread,
Jul 13, 2021, 4:09:03 AM7/13/21
to ArangoDB

(hypothetical example)

Say I have a users document group and another document group sessionTokens that store the session the users have. Each user can have multiple tokens but a token can only belong to one user. The association is done through edges.

Now if I use graph functions I can delete a token and the edge between the user and the token gets deleted automatically, and that is great. But what if I want to make sure that if a user is deleted, I want all their session tokens (vertices) to be deleted automatically as well (or else they will be orphan tokens)? Do I have to handle this in application code? Or is there a declarative way to ensure this type of integrity?

kmsz...@gmail.com

unread,
Aug 8, 2021, 4:35:45 AM8/8/21
to ArangoDB
Here is a suggestion: Don't make a separate token collection. Instead use a token object array within the User document and manage the token array with array functions. The overhead for tokens doesn't add any benefits.
Reply all
Reply to author
Forward
0 new messages