[ale] newb mysql question: unique table serial #s
Mike Harrison
meuon at geeklabs.com
Sun Mar 9 22:24:26 EDT 2008
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;
More information about the Ale
mailing list