Re: Table Updates ..

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Rudi Starcevic <rudi(at)oasis(dot)net(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Table Updates ..
Date: 2003-03-12 03:57:23
Message-ID: 200303111957.23061.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Rudi,

> If I have 3 tables :
>
> orders,
> products,
> orders_products ( join table for orders and products )
>
> If I insert an order with two products I have:
>
> 2 rows in the products table, ( the two products )
> 1 row in the orders table and ( one order )
> 2 rows in the orders_products table. ( two products for this order )
>
> So far so good. All that works well.
> But what if next week one the the products in the products table is
> updated and changed ?
> Then my order from last week is now different -- corrupted. It links to
> the same product_id but the product is changed.

If you're concerned with "freezing" the product characteristics at the time of
the order, the answer is to add all or most of the columns in the products
table to orders_products. Then, at the time of order finalization
(shipping? not sure) you copy those columns from products to order_products.

If you're into ORDMBS, you could even create orders_products as inheriting
products. But this isnt' required.

This will work better than a monthly log.

--
-Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rudi Starcevic 2003-03-12 04:07:50 Re: Table Updates ..
Previous Message Rudi Starcevic 2003-03-12 03:50:49 Table Updates ..