create table `test`.`user_relationship`( `first_user_id` int default '' not null comment 'ID of first user.', `second_user_id` int default '' not null comment 'ID of second user.', primary key (`first_user_id`,`second_user_id`) ); alter table `test`.`user_relationship` add index `second_user_fk`(`second_user_id`), add constraint `second_user_fk` foreign key (`second_user_id`) references `test`.`user`(`ID`); alter table `test`.`user_relationship` add index `first_user_fk`(`first_user_id`), add constraint `first_user_fk` foreign key (`first_user_id`) references `test`.`user`(`ID`); create unique index `PRIMARY` on `test`.`user_relationship`(`first_user_id`,`second_user_id`); create index `first_user_fk` on `test`.`user_relationship`(`first_user_id`); create index `second_user_fk` on `test`.`user_relationship`(`second_user_id`);