If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > A kınd of logging

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-04, 08:38
honest honest is offline
Registered User
 
Join Date: Apr 2004
Posts: 4
Exclamation A kınd of logging

Hi,
I have the following problem :
I have to keep track of every change of most of the columns in most of the tables in my database. I can explain the problem by an example: I keep my shopping list in a table (actually there lots of this kind of table in my db). I want to keep track of every change (update) in my list. This may be a kind of logging. Should I duplicate the necessary tables and keep the most actual values in first table and keep the history in the second one. Or, should I keep a single, seperate table for all of my db and keep key information together with the history data. Actually I'll need the last modified data in my ordinary world but I'll need the history data for reporting.
Thanks for your interest
Reply With Quote
  #2 (permalink)  
Old 04-20-04, 11:15
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
This is what we do to solve a similar problem. For tables we want to track all changes we dor this:

1) have a Timestamp column for whan it was updated last.
2) have a "log" table that is an exact copy structually with the exception of the Primary (and other unique) key.
3) have an insert trigger that inserts the record being inserted into the "log" table.
4) have an update trigger that writes the "new" values of all columns to the "log" table.

(note: the two triggers look identical except one if for INSERT and the other is for UPDATE).

We do not allow deletes so we do not have to log that. If you do, you would have to come up with a plan to handle that. Maybe an extra column in the "log" table that shows action (I=Insert, U=Update, D=Delete).

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 04-21-04, 03:17
honest honest is offline
Registered User
 
Join Date: Apr 2004
Posts: 4
Wink

HI,
Your suggestıon was one of the possibilities I thought about. However, I'm looking for smth that would have minimum effect on the performance of the every day jobs. I mean, it would be better if the solution is not in the transaction of the operation itself. Have you ever heard about a solutıon with an additional database (call it log database) ? You write everyday transaction queries to a text file and periodically read, parse and prepare the track data in the 'log' database; or smth like this.
Thanks a lot.
Reply With Quote
  #4 (permalink)  
Old 04-21-04, 04:55
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
DB2 Data Propogator aka Replication may be a choice then ..

Replication reads DB2 log files to track changes

HTH

sAthyaram

Quote:
Originally posted by honest
HI,
Your suggestıon was one of the possibilities I thought about. However, I'm looking for smth that would have minimum effect on the performance of the every day jobs. I mean, it would be better if the solution is not in the transaction of the operation itself. Have you ever heard about a solutıon with an additional database (call it log database) ? You write everyday transaction queries to a text file and periodically read, parse and prepare the track data in the 'log' database; or smth like this.
Thanks a lot.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 04-22-04, 03:55
honest honest is offline
Registered User
 
Join Date: Apr 2004
Posts: 4
Post

Hi,
Thank you sAthyaram but it is my fault that I did not mentioned the necessity of database independence. As a result, if we use Data Propagator then the customer will need DataJoiner for non-DB2 databases. Also the 'spill' tables used in Data Propagator will decrease the performance..
Any more suggestion

(We use Db2 v8)
Reply With Quote
  #6 (permalink)  
Old 04-22-04, 11:00
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Well, you can maintain the history in the same table, ie, you do not have any updates in your application ... All updates are performed as INSERTS leaving the previous set of rows intact ...

The usefulness of this solution anyway depends on workload , ie, your SELECTS may be perform slower if you use this technique ...

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On