[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] newb mysql question: unique table serial #s
- Subject: [ale] newb mysql question: unique table serial #s
- From: meuon at geeklabs.com (Mike Harrison)
- Date: Sun, 9 Mar 2008 22:24:26 -0400 (EDT)
- In-reply-to: <[email protected]>
- References: <[email protected]>
On Sun, 9 Mar 2008, Chris Woodfield wrote:
> I'm working on a perl script that talks to mysql for the first time,
> and I'm coming up with all sorts of basic questions as to how to
> structure the database table.
>
> One thing that my db will need is a sequential index/serial number, so
> that records can be returned and sorted in sequence to their entry. I
> know timestamps could do this, but I can't have duplicates.
Almost all of my tables start with a generic field called 'uniq'
which is a uniq ID number used in various generic recyclable functions
for selecting just that record.
An example:
DROP TABLE IF EXISTS `stuff`;
CREATE TABLE `stuff` (
`uniq` int(10) NOT NULL auto_increment,
`stuff` text default '',
`lastmod` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`uniq`),
UNIQUE KEY `id` (`uniq`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;