create table `test`.`useraccess`( `ID` int not null auto_increment, `USERID` int, `IPADDRESS` varchar(255) default '' not null, primary key (`ID`) ); alter table `test`.`useraccess` add index `FK_userid`(`USERID`), add constraint `FK_userid` foreign key (`USERID`) references `test`.`user`(`ID`); create unique index `PRIMARY` on `test`.`useraccess`(`ID`); create index `FK_userid` on `test`.`useraccess`(`USERID`);