Lists: | pgsql-sql |
---|
From: | Marius Andreiana <marius(at)wdg(dot)ro> |
---|---|
To: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Keeping information changes history |
Date: | 2002-01-24 18:32:57 |
Message-ID: | 1011897177.2277.13.camel@aurora.wdg.ro |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Hi
I need to keep information changes history for people in our
application.
e.g. when their address was changed I need to remember who changed it
(staff or member), when and to what was changed.
I don't know what's the standard approach to this problem. I thought
of having another address table, say addresses_history, same structure
as usual table, but with some extra fields: type of user and user id who
made the change, and time stamp.
Every time a change is made to addresses table also insert the proper
record in addresses_history with a trigger. But I need to know
information about the user who changed it in database, not only the
application, so where to keep it?
So I should add other columns to addresses table for this (user id and
type of user)
Any suggestions for improving or confirmations that this approach will
do the job greatly appreciated!
--
Marius Andreiana
--
You don't have to go to jail for helping your neighbour
http://www.gnu.org/philosophy/
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Marius Andreiana <marius(at)wdg(dot)ro> |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Keeping information changes history |
Date: | 2002-01-24 19:00:02 |
Message-ID: | 16617.1011898802@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Marius Andreiana <marius(at)wdg(dot)ro> writes:
> I need to keep information changes history for people in our
> application.
> e.g. when their address was changed I need to remember who changed it
> (staff or member), when and to what was changed.
> I don't know what's the standard approach to this problem. I thought
> of having another address table, say addresses_history, same structure
> as usual table, but with some extra fields: type of user and user id who
> made the change, and time stamp.
> Every time a change is made to addresses table also insert the proper
> record in addresses_history with a trigger. But I need to know
> information about the user who changed it in database, not only the
> application, so where to keep it?
> So I should add other columns to addresses table for this (user id and
> type of user)
Yup, that's the standard approach, and using triggers to add entries to
the history table is exactly how it's done.
regards, tom lane