-- a foo table create table foo ( id int not null primary key auto_increment, foo varchar(255) not null ); -- a bar table create table bar ( id int not null primary key auto_increment, bar varchar(255) not null ); -- a linking table create table foo_bar ( foo_id int not null references foo(id), bar_id int not null references bar(id) ); -- a naked qux table create table qux ( id int not null primary key auto_increment, qux varchar(255) not null );