Tracking historical data in Database
Showing comments 1 to 6 of total 6 on page 1 of 1
robinalexRank: 1
Emp_ID |
Emp_Adr |
123456 |
14810 SE 26th Drive |
Ch_Date |
Emp_ID |
Emp_Adr |
7/15/2009 |
123456 |
22212 NE 55th St |
8/26/2009 |
123456 |
15478 SE 7th PL |
Emp_ID |
Emp_Adr |
123456 |
14810 SE 26th Drive |
Ch_Date |
Ch_Table |
Ch_Key |
Ch_Field |
Old_Value |
New_Value |
7/15/2009 |
m2_emp_contact |
123456 |
emp_adr |
22212 NE 55th St |
15478 SE 7th PL |
8/26/2009 |
m2_emp_contact |
123456 |
emp_adr |
15478 SE 7th PL |
14810 SE 26th Drive |
Emp_ID |
Effective_Date |
Expiration_Date |
Emp_Adr |
123456 |
1/1/2009 |
7/15/2009 |
22212 NE 55th St |
123456 |
7/15/2009 |
8/26/2009 |
15478 SE 7th PL |
123456 |
8/26/2009 |
12/31/9999 |
14810 SE 26th Drive |
Emp_ID |
Trans_Number |
Emp_Adr |
123456 |
1 |
22212 NE 55th St |
123456 |
2 |
15478 SE 7th PL |
123456 |
3 |
14810 SE 26th Drive |
Object_ID |
Obj_Key |
Transaction_Date |
Trans_Number |
Employee |
123456 |
1/1/2009 |
1 |
Employee |
123456 |
7/15/2009 |
2 |
Employee |
123456 |
8/26/2009 |
3 |
Emp_ID |
Trans_Number |
Emp_Adr |
123456 |
1 |
22212 NE 55th St |
123456 |
2 |
15478 SE 7th PL |
123456 |
3 |
14810 SE 26th Drive |
123456 |
4 |
14820 SE 26th Drive |
Object_ID |
Obj_Key |
Transaction_Date |
Trans_Number |
Employee |
123456 |
1/1/2009 |
1 |
Employee |
123456 |
7/15/2009 |
2 |
Employee |
123456 |
8/26/2009 |
3 |
Employee |
123456 |
8/20/2009 |
4 |
Emp_ID |
Effective_Date |
Expiration_Date |
Emp_Adr |
123456 |
1/1/2009 |
7/15/2009 |
22212 NE 55th St |
123456 |
7/15/2009 |
8/20/2009 |
15478 SE 7th PL |
123456 |
8/26/2009 |
8/26/2009 |
14810 SE 26th Drive |
123456 |
8/20/2009 |
12/31/9999 |
14820 SE 26th Drive |
krisRank: 14
I feel to have a flag field in the table to indicate whether an address is current address or an old address. This makes the query process more simple and standard.
robinalexRank: 1
With an existing field we can track the present address. So, having an additional flag filed lead to data redundancy; currently an infinite date is set as expiration date. If you feel that, having a date value to that filed is illogical, you can have null value assigned.. But, getting data for certain date becomes difficult; you need to write one logic for present and another for past… BTW These methods for tracking data for any past date… For example, if want to know “to which address” of the client a communication has sent on certain date, you can track it from date..
It would be great if you could explain more about the flag filed standard which you mentioned, and how it simplifies the things?
arvind9n...Rank: 49
asighRank: 2
1. Make sure you have and index column -- that will auto increment.
2. Put a Trigger on the date changed field. As soon as that changes you can fire a SP and update your history table.
3. Carry the index over to the history table for tracking.
4. Depends how much 'history' you want to carry over. You want to store the previous address too. If yes, then just keep a separate table that holds all the addresses that an index held with the date stamp.
neonevinRank: 51
Most of the ERPs today are using the data tracking mechanism. The simplest of these i ve seen is using a
combination of effective dated and effective status logics,
Effective dated logic will help you to filter out latest transactions (using max(EFFDT) in ur where codition) as well as track changes to data. (but normally all changes to data will not be tracked)
Effeective status will help you to identify relevant data (i.e EFF_STATUS is active or inactive)