Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0OJ0Ml37476 for ; Thu, 24 Jan 2002 14:00:22 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g0OJ02f16620; Thu, 24 Jan 2002 14:00:02 -0500 (EST) To: Marius Andreiana cc: pgsql-sql Subject: Re: Keeping information changes history In-reply-to: <1011897177.2277.13.camel@aurora.wdg.ro> References: <1011897177.2277.13.camel@aurora.wdg.ro> Comments: In-reply-to Marius Andreiana message dated "24 Jan 2002 20:32:57 +0200" Date: Thu, 24 Jan 2002 14:00:02 -0500 Message-ID: <16617.1011898802@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200201/277 X-Sequence-Number: 6361 Marius Andreiana 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