Database Design Advice

David Cantrell david at cantrell.org.uk
Fri Nov 8 19:33:11 GMT 2013


On 08/11/2013 18:08, James Laver wrote:
> On Fri, Nov 8, 2013 at 5:22 PM, Yitzchak Scott-Thoennes
> <sthoenna at gmail.com> wrote:
>> On Fri, Nov 8, 2013 at 12:38 AM, Mark Stringer <mark at repixl.com> wrote:
>>> I'd guess that the date_created is being stored in the table, so could be
>>> used to order the records without the need for a serial, if ordering is the
>>> only concern.
>> Never use date/times as unique identifiers/sort keys.
> I'll agree with the former, but what's the reasoning behind the latter?

Because you might need to know which of two events at 
2013-11-08Z19:31:04 happened first. Sure you could use microseconds or 
whatever to get better resolution, but all that does is make the problem 
less likely, it doesn't make it go away.  You also normally want sort 
order to be consistent. If you have two records where the sort field is 
the same, the order they come out is going to be unpredictable.

-- 
David Cantrell | Bourgeois reactionary pig

     fdisk format reinstall, doo-dah, doo-dah;
     fdisk format reinstall, it's the Windows way


More information about the london.pm mailing list