Re: Referencing a view? - Mailing list pgsql-sql

From Grigoriy G. Vovk
Subject Re: Referencing a view?
Date
Msg-id 20010713175036.P886-100000@callisto.internal.linustech.com.cy
Whole thread Raw
In response to Re: Referencing a view?  ("James Orr" <james@lrgmail.com>)
List pgsql-sql
Jul 13, 09:41 -0400, James Orr wrote:

> Thanks for all the responses!  The one from Grigoriy was particularly
> interesting, I hadn't thought of that approach.
>
> However, I came to the realization that if somebody changes their address, I
> don't want it to be changed on previous orders.  So I think i'll change the
> orders table to contain the actual address information and use an INSERT ...
> SELECT instead.  That way I can be sure I have an accurate record of all
> orders.
Yes, its really a problem... When  information sometime changes but we
want to keep old information for depending data. (If I understand correctly
what about you are speaking).
But, you can resolve the problem if will copy information about address
for executed order in a different place as a text, not as a link to the
table 'address'. So, after execution of an order you will take current
address by the link and copy all information (may be, as one field
everything - concat all fields from the address together). Its a one
solution.
Next - you can use many addresses for an entity, and work only with some
of them, 'valid', or 'current', as do you like, not with all.
So, you will have full addresses history - when was changed, etc. And the
order will always links to correct address, even now current address is
different.
You can do it by add field 'current' bool in the table 'address' or
create additional table 'current_address' which will have 'id_entity' and
'id_address', so if you will do a search on 'current_address' you got
a list of current addresses, in case you will do a search on 'address' -
you got a list of all addresses. I prefere to create additional table.
May be I've explained not well - ask, I'll type an database structure
example, for developers it may be easy way :)


my best regards,
----------------
Grigoriy G. Vovk



pgsql-sql by date:

Previous
From: "James Orr"
Date:
Subject: Re: Referencing a view?
Next
From: "Josh Berkus"
Date:
Subject: Date Validation?