How do I prevent parentless child

Greetings - Just started using a week ago and love it. Is there a way to prevent an item from being deleted once it has been referenced in another item (on a different table) but allow it to be delete-able after all references have been removed.

Thanks All!\

I don’t believe this is possible in the database tables - what scenario do you envision this occurring with?

Thanks John. I have a field in a employee hx table that pulls from an employee type table. I want to prevent a person from deleting an “active” entry that has been used but allow them to delete an unused entry. Am I :peanuts:?

By “active” and “unused” entry I’m assuming you’re trying to optimize your database tables based on usage. If you have a empty field I don’t believe it creates any type of performance issues - is that what you are concerned about?

No - sorry for the confusion. I have numerous drop down boxes throughout the application that are dynamic. The source for these drop down boxes are able to be controlled. Let’s look at Users. Throughout the application, Users is called as a field in other data-sets. I want to prevent the end user from deleting another user who’s account is referenced elsewhere in the application. However, if the person was added accidentally (duplicate for example,) the end user should be able to delete the duplicate after all references to the duplicate have been update with the origination item.

In Bubble you are responsible for your own referential integrity of the database (or not, as the case may be).

This is one of the reasons I usually recommend having a two way reference between tables.

So if we had “Team” for example, which has “Team Leader” field of type “User” then on the User I would create “TeamLeaderOf” field, type “Team” and select it to be a list.

That way the delete button on User can have a simple condition that says “Enable this button only when TeamLeaderOf is Empty”.

So yes, it is possible, but you have to do it yourself, rather on a constraint on the database.

1 Like