Currently having a simple schema, a sites
table and an items
table.
Sites
own many items
, items
has a siteId
column to store the reference of the site which owns it.
I’d like to be able to enforce a condition when querying items
, meaning returning an error if it is not queried with a siteId; in practice :
select * from items
would failselect * from items where siteId = 1
would succeed, albeit a site record with id 1 exists
Can easily be achieved on an application level;
I recently started investigating further into row level policies, roles, functions etc… which I found verify interesting as it enables lower level setups. That is, i’m still new about it and lack of understanding/knowledge. Does the use case describe above could simply resides within sql, via a combination of policies, function etc… ?