PSQL Constraint for Parent Children Relationship #2359
-
|
Hi all @supabase users is there any way I can make a constraint to validate the integrity of a relationship? Use Case: This is ok, but with some limitation, as you can see you are limited to max of 4 options. Typical polling system can add more options. How can I achieve this? I want to achieve this at db level so I can make use of supabase studio insert row functionality with validation... Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Hey @sandbox-apps, Edit: an array was the solution here, see below. For your case, I think you could create a trigger that enforces the constraint(does a Hard to come with a snippet without a sample schema, but there's an example here(see the |
Beta Was this translation helpful? Give feedback.
Hey @sandbox-apps,
Edit: an array was the solution here, see below.
For your case, I think you could create a trigger that enforces the constraint(does a
raise foreign_key_violationinside).Hard to come with a snippet without a sample schema, but there's an example here(see the
check_role_exists()trigger function).