MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Mike Hillyer Date:June 19 2003 3:31pm
Subject:RE: selecting PRIMARY KEY when there is no unique value
View as plain text  
When I last did an invoice-type project, he had the header table with an
invoice# as PRIMARY KEY, then we had an invoice_line table with a rowid
PRIMARY KEY as auto-increment and a invoice# with a non-unique key
INDEX. This worked fine for our purposes, so I would probably go with
option #1 I guess.

Regards,
Mike Hillyer
www.vbmysql.com
 

> -----Original Message-----
> From: Mojtaba Faridzad [mailto:mfaridzad@stripped] 
> Sent: Thursday, June 19, 2003 9:16 AM
> To: mysql@stripped
> Subject: selecting PRIMARY KEY when there is no unique value
> 
> 
> 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?
> 
> thank
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/mysql?> unsub=mhillyer@stripped
> 
> 
Thread
Odd thingDave Christensen19 Jun
  • Re: Odd thingDon Read19 Jun
RE: Odd thingJay Blanchard19 Jun
RE: Odd thingDave Christensen19 Jun
  • RE: Odd thingMatthew Smith19 Jun
RE: Odd thingJay Blanchard19 Jun
RE: Odd thingDallas Dickey19 Jun
  • selecting PRIMARY KEY when there is no unique valueMojtaba Faridzad19 Jun
    • Re: selecting PRIMARY KEY when there is no unique valueBruce Feist19 Jun
    • Re: selecting PRIMARY KEY when there is no unique valuePaul DuBois19 Jun
    • Re: selecting PRIMARY KEY when there is no unique valueDon Read19 Jun
  • Re: selecting PRIMARY KEY when there is no unique valuePeterWR19 Jun
  • Re: selecting PRIMARY KEY when there is no unique valueMichael Conlen19 Jun
  • Re: selecting PRIMARY KEY when there is no unique valueMojtaba Faridzad19 Jun
  • Re: selecting PRIMARY KEY when there is no unique valueKen Menzel19 Jun
  • how to limit COUNT(*)Mojtaba Faridzad22 Jul
  • Re: how to limit COUNT(*)gerald_clark22 Jul
  • Re: how to limit COUNT(*)Jerry22 Jul
  • Re: how to limit COUNT(*)Mojtaba Faridzad22 Jul
    • Re: how to limit COUNT(*)Fred van Engen22 Jul
  • Re: how to limit COUNT(*)Viorel Dragomir22 Jul
  • Re: how to limit COUNT(*)Mojtaba Faridzad22 Jul
  • Re: how to limit COUNT(*)Yves Goergen22 Jul
    • RE: how to limit COUNT(*)Mike Brum22 Jul
      • Re: how to limit COUNT(*)Mojtaba Faridzad22 Jul
  • Re: how to limit COUNT(*)gerald_clark22 Jul
    • Re: how to limit COUNT(*)Keith C. Ivey22 Jul
  • Re: how to limit COUNT(*)Mojtaba Faridzad22 Jul
    • Re: how to limit COUNT(*)Fred van Engen22 Jul
RE: Odd thingDallas Dickey19 Jun
RE: Odd thingJay Blanchard19 Jun
RE: Odd thingDave Christensen19 Jun
RE: selecting PRIMARY KEY when there is no unique valueMike Hillyer19 Jun
RE: Odd thingDave Christensen19 Jun
RE: Odd thingDave Christensen19 Jun
RE: Odd thingDave Christensen19 Jun
  • Re: Odd thinggerald_clark19 Jun
RE: Odd thingDave Christensen19 Jun