On 19-Jun-2003 Mojtaba Faridzad wrote: Please don't hi-jack threads.
> Hi, > > In a docuement such as Invoice Form, we have a header and a couple of > records for the detail. In header table, Invoice# can be the PRIMARY KEY > but > in detail table, Invoice# is not unique. I think there are two solutions > to > choose a Primary Key (in MyISAM type) : > > 1) Adding an id field ( auto_increment ) and choose it as PRIMARY KEY > in this case we have to add another index on Invoice# for making relation > with the header table > > 2) There is another field in detail table with "timestamp" type for > keeping > the last change on the record. I want to select ( Invoice# + myTimestamp > ) > for PRIMARY KEY. in this case I don't need to add a new fields ( id ) and > another index ( on Invoice# ) to the table. > > which one do you prefer and usually use? Number one (with a composite key). table invoice_line ( idinv int unsigned not null, // invoice number line tinyint unsigned auto_increment, // line number idprod, qty, uom, price, cogs, // product shipped ... primary key(idinv, line) ) Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. (53kr33t w0rdz: sql table query) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]