How to set up last access (timestamptz) in table 1( basic info table) when working with many other tables having foreign key from table 1? Let's say the database have 5 tables for sake of simplicity (there're many more in reality). Table 1 has the basic information of a user which is not changed so often. However, the other tables are accessed very often. All these other tables have the user-id as the foreign key. I need to make a column lastAccess in table 1 such that whenever the user works with any of the table, user's lastAccess in table 1 is updated.

I'm working with [python-socketio] (https://github.com/miguelgrinberg/python-socketio) server connected to PostgreSQL database using python-psycopg2 connector.

It seems like a task which every person working with databases should know. I am new to working with RDBMS and exactly find a way to do it.
A general direction, if a solution is not possible, will also be really appreciated.
I have two solutions:


Create a lastAccess column on all 5 of the tables. Create database triggers on each table to update it's corresponding lastAccess column. This will allow you to track when each table is updated.
Create lastAccess on Table 1. Then create triggers on tables 2,3,4,5 that will update the lastAccess column on Table 1.