On Friday 20 October 2006 15:15, Richard Hosking wrote:
>   item_1 VARCHAR(20) NOT NULL,
>     item_2 VARCHAR(20),
>     item_3 VARCHAR(20),
>     item_4 VARCHAR(20),
>     item_5 VARCHAR(20),

Don't artificially restrict yourself to 5 items - also makes searching for 
billed items eg for statistics a lot harder

your transaction will have one or more items.
do instead:

create table items (
        id serial primary key, 
        transaction_id integer references transactions(id),
        ...
);

You are not likely to ever run lots of queries/time over and over again for 
all items of a given billing transaction, so there is no advantage in 
denormalizing here

Re table name "transaction" - this is a reserved word in many SQL dialects.
rather call it billing_transaction or invoice or some such

It also makes SQL code more readable if you use plural for all table names - 
only realized that myself afetr reading a lot of RoR code

Horst        
_______________________________________________
Gpcg_talk mailing list
[email protected]
http://ozdocit.org/cgi-bin/mailman/listinfo/gpcg_talk

Reply via email to