Re: Way to design "history" in DBs
Date: 2000/03/02
Message-ID: <38BDD94F.7E10BF22_at_arcavia.com>#1/1
Bernhard Nemec wrote:
>
> I am creating a new relational database and don't know the best way to
> design the following special requirement:
>
> I have a table of entities (items) that are received, stored in various
> places, and treated in several possible ways. The user's requirement is
> now that not only the actual storage position and state of each item can
> be queried, but also its "history". That is, he wants to query when the
> item was received, when it was dislocated, and when it was treated in
> which way by which employee.
> You could think of a logfile that every item carries along, where all
> relevant happenings are written to.
>
> Are there common ways how to design such a thing in an E-R model?
The answer is a balance between efficiency and simplicity, as usual.
TABLE DEFINITION: MyTable
Key MyField1 DateEffective ChangeInfo
QUERY THAT RESULTS IN A CURRENT VIEW OF TABLE
SELECT
*
FROM
MyTable A, ( SELECT Key Max(DateEffective) FROM MyTable GROUPBY Key ) B WHERE A.Key=B.Key AND A.DateEffective=B.DateEffective
;
But this method can be wasteful if the tables have many attributes, and the
Kyle Lahnakoski Arcavia Software Ltd. (416) 892-7784 http://www.arcavia.comReceived on Thu Mar 02 2000 - 00:00:00 CET