> -----Original Message-----
> From: John Comerford [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 17, 2007 10:50 PM
> To: mysql@lists.mysql.com
> Subject: Millisecond time stamp
> 
> Hi Folks,
> 
> I am putting together a table to hold log entries.  I was going to index
> it on a field with a type of TimeStamp.  Unfortunately this will not
> suit my needs because I could have more than one log entry per second.
> As far as my (limited) knowledge goes I have two options to get around
> this:
> 
> A) One character string contain a string I build with the date and
> milliseconds tagged onto the end
> b) Two separate fields  Field1 TimeStamp  Field2 Milliseconds

WHY are you indexing the Timestamp?  It should not be your primary key
because, as you point out, it might allow duplicates.  Even case B is not
foolproof.  If you're indexing it for searching, then your application
should be prepared to handle multiple log records for any value.

For uniqueness, add an auto_increment primary key column.  That way, you can
tell two+ log records apart even when they have the same timestamp.

Tim
 
> I am leaning towards approach B, but saying that it's more gut instinct
> than anything else.  My questions are:
> 
> 1) Is there some a better way to achieve what I want ?
> 2) Which of the two methods above would/do you use ?
> 
> I am using PHP to access the database and I am fairly new to both PHP
> and MySQL.
> 
> TIA,
>   JC
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to