Support Topics Documentation Slack YouTube Blog

Referential integrity constraint with user object id in another table

(Lanre O.) #1

I want to link the objectId from the users table to a column called userObjectId in table B and enforce a referential integrity constraint on table B?


(Sergey Chupov) #2

You can use relation for that, but it depends on what constraints exactly do you need? We do not provide not null constraints on relation columns as of yet unfortunately.

(Lanre O.) #3

I want to use the object_id in the user table in another table - I want to make sure that the object_id cannot be deleted in the user table if it used in another table.

(Sergey Chupov) #4

Well, you can implement this using beforeDelete event handler - you can imagine it as an analogy to a trigger in classic databases. Inside of the handler you will check whether there is any object referencing the current object which is attempted to be deleted, and if there is - either reject the operation or do some cleanup logic you need.