[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP3] Database Design
From:       mcgarry () tig ! com ! au
Date:       1999-12-05 17:29:12
[Download RAW message or body]

Howdy all,

> Uniqueness of what exactly? Order can contain many products, very good. So
> you make a field in the orders table, which will accumulate product IDs

You almost certainly need to be accumulating more than product IDs for
each item though, you need to have a total description for that item at
the time it was bought so that changing the price (and any other
properties) of an item in future doesn't screw with old orders.

There's two ways (at least) of achieving that. Either duplicate the
properties of an item (into an order or order_item table) every time
it's ordered or simply never change the properties of an item in the
standard item table(s), instead insert a new record with the updated
properties and mark the old record as historic.

The more I think about it I'm tending towards the second option.

> for this order. If you are in love with normal forms, you might instead
> make this relationship as a separate Order-Product relation table
> (quantity will go there too, as the relationship attribute), though
> IMHO it's an overkill, since you rarely seek "orders which have this
> product". But if you will, go for "normalized" design, even though it will
> cost you a number of DB queries for each order.
 
I'd almost certainly plump for normalising, you may 'rarely seek "orders
which have this
product"' but I've seen too many storefronts where the information I
want is buried in some congolmerate text field and it becomes boring
very quickly. Even if you don't see a reason it would be useful now, in
the future you may be grateful for it.

Paul

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe@lists.php.net
To subscribe to the digest, e-mail: php3-digest-subscribe@lists.php.net
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin@lists.php.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic