I’m building a web application that will allow users to collaborate to build a giant graph together (with a front end UI like this, https://reactflow.dev/). I’m considering using the Realtime Database as the main database so that users can immediately see changes that other users are making to the part of the graph they are currently viewing/editing (hopefully, this will prevent many conflicting edits).
For the most part, the graph will be open to the world for anyone with a verified email address to edit (in the spirit of Wikipedia) and so will be vulnerable to vandalism. For that reason, it's critical that everything be carefully versioned, and that the database be resilient to malicious intentional corruption.
The way I’m planning to structure this in the Realtime Database is to have a list of graph nodes. Each node will contain a list of the nodes it is connected to. Web clients will have permissions to create and update nodes in this node list.
Whenever a web client creates or updates a node in the node list, it will trigger a database function that will record the latest version of the node in a separate list of node versions. This node version list will not be writable by the web app clients, only readable. This way the version information cannot be maliciously corrupted, and it will always be possible to roll back malicious changes to the nodes themselves using the version information.
From my reading of the Realtime Database documentation, it seems like using triggers to call functions to record version information should be fairly straight forward (but I’m not entirely sure).
On the other hand based on reading the documentation, it’s not clear to me that enforcing database validation will be straightforward. Whenever a link is created between two nodes, there needs to be an update to BOTH nodes updating their lists of nodes they are linked to. Whenever a link is deleted between two nodes, BOTH nodes must also be updated to remove the link to the other. Is it possible to write validation rules that would enforce the requirement that both nodes are added or deleted to their respective node link lists simultaneously?
Overall, does this structure make sense? Any obvious problems with the way I'm thinking about the implementation? Does it sound like Realtime Database will be a good fit for this project?
I’m building a web application that will allow users to collaborate to build a giant graph together (with a front end UI like this, https://reactflow.dev/). I’m considering using the Realtime Database as the main database so that users can immediately see changes that other users are making to the part of the graph they are currently viewing/editing (hopefully, this will prevent many conflicting edits).
For the most part, the graph will be open to the world for anyone with a verified email address to edit (in the spirit of Wikipedia) and so will be vulnerable to vandalism. For that reason, it's critical that everything be carefully versioned, and that the database be resilient to malicious intentional corruption.
The way I’m planning to structure this in the Realtime Database is to have a list of graph nodes. Each node will contain a list of the nodes it is connected to. Web clients will have permissions to create and update nodes in this node list.
Whenever a web client creates or updates a node in the node list, it will trigger a database function that will record the latest version of the node in a separate list of node versions. This node version list will not be writable by the web app clients, only readable. This way the version information cannot be maliciously corrupted, and it will always be possible to roll back malicious changes to the nodes themselves using the version information.
From my reading of the Realtime Database documentation, it seems like using triggers to call functions to record version information should be fairly straight forward (but I’m not entirely sure).
On the other hand based on reading the documentation, it’s not clear to me that enforcing database validation will be straightforward. Whenever a link is created between two nodes, there needs to be an update to BOTH nodes updating their lists of nodes they are linked to. Whenever a link is deleted between two nodes, BOTH nodes must also be updated to remove the link to the other. Is it possible to write validation rules that would enforce the requirement that both nodes are added or deleted to their respective node link lists simultaneously?
Overall, does this structure make sense? Any obvious problems with the way I'm thinking about the implementation? Does it sound like Realtime Database will be a good fit for this project?
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/92904be7-a8ec-4a5e-96ea-f24793a862cbn%40googlegroups.com.