mysql> create table test2 (group_id int unsigned not null auto_increment,object_id int unsigned not null, primary key (group_id,object_id)); Query OK, 0 rows affected (0.04 sec) mysql> insert into test2 values (null,1),(null,2); Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from test2; +----------+-----------+ | group_id | object_id | +----------+-----------+ | 1 | 1 | | 2 | 2 | +----------+-----------+ 2 rows in set (0.00 sec) mysql> insert into test2 values (1,2),(null,1); Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from test2; +----------+-----------+ | group_id | object_id | +----------+-----------+ | 1 | 1 | | 1 | 2 | | 2 | 2 | | 3 | 1 | +----------+-----------+ 4 rows in set (0.00 sec)