Based on the above information, I would say that you need to write a database trigger and consider using virtual private database. Allow me also to recommend the following noble work from the end of the last century: Elementary Logic, by Benson Mates (Oxford University Press, ISBN: 019501491X)