I am working on an app to allow a non-technical user to do "admin" type functions within our system - one of which is to delete users.
On one level this should be "easy", even if I have to delete rows from multiple tables that all use the "userid" as a foreign key, I can either add those statements into one query, or perhaps chain queries to trigger on success?
But here is where I am getting a little stuck. I need to delete multiple records from multiple tables based on DIFFERENT foreign keys, which eventually lead back to the user id
DELETE PresentationDiagram WHERE diagramDocumentId =
DELETE DiagramDocument WHERE documentId =
DELETE Document WHERE projectID =
DELETE Presentation WHERE projectID =
DELETE Project WHERE ownerID =
DELETE User WHERE emailAddress = [EMAIL]
Right now I have created a series of queries that we run manually in the database; some are simple, and others a little more complex:
delete from "PresentationDiagram"
where "diagramDocumentId" in (
select id from "DiagramDocument"
where "documentID" in (
select id from "Document"
where "projectID" in (
select "id" from "Project" where "ownerID" in (
select "id" from "User" where "emailAddress" = '[EMAIL]')
)
)
);
Is there an easy - or even logical way, to do this within Retool?