Deleting "nested" data records

Great thread. I had the same thought this week after deleting some records that had pointers to other tables.
This is a common “best practice” with relational data structures. I’ve seen many low/no-code platform already solve this. It’s usually done as an option when you set a field as a reference to another table. That way you don’t have to manual define logic like the above solution.
The reason you need an option at the field level is that there are usually at least two common scenarios.

  1. A table of user properties like that has a field pointing to a user record. If the user record is deleted there is really no need for the properties. Many to many tables are another case. Recommended action: cascade delete record(s)

  2. A table of contact records has a field pointing to a user record as the owner of the contact. When the user record is deleted you may not want to delete the contact record, but you do want to clear the value since the pointer is no longer value. Recommended action: clear reference values.

From what I can see Bubble is handing all deletes with process #2.

I thought this would have been a great use of the database change trigger (alpha testing) but I can’t seem to get it to work. My assumption is that the delete event that Bubble is doing in the background to remove the dead pointer is not triggering a database change event.
Adding @allenyang since it’s something to consider for this the database trigger events. Or at least give us an easier way to cascade delete reference records with a field config of some sort since even if database trigger did work, we’d have to create delete workflows on every table we’d want to delete records on.

I have a good test scenario in my instance if I can test anything else for anyone. It’s a private instance that has the new db trigger feature so sorry I can’t share it for viewing.

1 Like