With Postgres you can associate events and notifications to tables.
This function allows you to detect and handle such events.
With no arguments, resets and removes any callback you might have
put previously, and any polling cycle.
With one argument, sets the notification callback (there can be only
one for each sqlobject).
With two arguments, sets a notification callback and sets a polling
cycle.
The polling cycle is necessary because of the way notifications are
delivered, that is piggyback with a query result. This means that
if you don't do any query, you'll receive no notification. The polling
cycle starts a call_out cycle which will do an empty query when
the specified interval expires, so that pending notifications
may be delivered.
The callback function must return no value, and takes a string argument,
which will be the name of the table on which the notification event
has occurred. In future versions, support for user-specified arguments
will be added.