Constraints that fire on query/touch


It's an idea I've had for some time, but I'm not sure if it's useful. 
Now constraints can fire on insert, delete, or update. 
Would a constraint that fires whenever a certain column is queried or touched at all be useful? 

I was thinking about the use case and to be honest… I gave up :sweat_smile:

Imagine we allow constraints on SELECT that means we also allow loosely defined domains so we need to execute extra validation on the SELECT and now imagine the cost of it if we select say 1000 rows.

Constraints are all about data correctness, data quality and controlled input, all before the actual SELECT, when you have eventual good data quality.


Nowadays there are applications that need to register/log who consulted data and at what time. Think of a patient treatment application where you need to know who consulted a patient dossier when. Or a policing application that has the same need.