I have two append-only tables, one of which has a foreign key to another.
For the purpose of this question, I'll call them sets and items.
sets has an unique id.
items has a unique id and a foreign key to sets.id.
How I work with these tables in code is that in a transaction, I create a sets row and several items rows that reference this sets row.
After this initial operation, I'd like to make it impossible to write any more items rows that would refer to that sets row, preferably on the database level with triggers, constraints, or other means to achieve that. In that sense, the sets row is closed for accepting any more items.
Is there a way to achieve what I envision here with Postgres?
And secondly, is this even a good practice to do that on database level?