▲ | hk1337 5 days ago | |
Pretty much yeah. I think you need to stay somewhat vigilant because it can creep in under the guise of validating data. Triggers is something I was thinking about that is grossly misused. | ||
▲ | porridgeraisin 4 days ago | parent [-] | |
I like using triggers for validation important for maintaining data integrity. Example: let's say you have a parent table P whose rows are soft deleted (update P set _deleted=1 where id=?) and a child table C (foreign key on P.id) On delete cascade isn't gonna work here obviously. So I use a trigger to emulate on delete cascade. Also, I've seen triggers to cancel transactions raise abort(..) if they violate some property that can't be retrofitted into a proper db constraint due to team politics at a previous workplace. |