• MySQL

    Using Multiple Sequences in a Table

    Recently, I wanted to use multiple sequences in a table.  I wanted to generate a new sequence for every event for the id of its registrants. The table structure was something like this : CREATE TABLE registrants ( event_id INT NOT NULL, id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100), email VARCHAR(100), address VARCHAR(100), PRIMARY KEY ( event_id, id ) ) ; But I ran into a problem. This works only for MyISAM and BDB tables. You can use AUTO_INCREMENT on a secondary column in a multiple-column index only for MyISAM and BDB tables. BDB isn’t supported any longer from MySQL 5.1 and I didn’t want to use MyISAM as my…