Hi there,
I,ve been doing history tables for some time now in databases but never put to much effort or thought into it. I wonder what is the best practice out there.
my main goal is to record any changes to a record for a particular day. If more than one change happens in a day then then only one history record will exist. I need to record the date the record was changed also as when I retrieve data I need to pull the correct correct from history as it was at a particular time.
So for example I have a customers table and what to pull out what their address was for a particular date. My Sprocs like get Cust details will take in an optional date and if no date is passed in then it returns the most recent record.
So heres what I was looking for advice on... and anything else.
Do I keep the history table in the same table and use a logical delete flag to hide the historial ones. I normally dont do this as some tables can change a lot and have lots of records.
Do I use a seperate table that mirrors the main table. I usally do this
Should I only put change records into the history table and not the current one.
What is the most efficent want given a date to pull out the right record... get every record for a customer <= date passed in and then sort by most recent date and take the top.
Thanks for all the help... regards M
↧