mysql - Creating a table with two foreign keys fail -


suppose want create table login page hold username , password , reference in other tables storing roles.

create table login (  username varchar(50) not null,  password varchar(50) not null,  primary key (username) );  create table user (  username varchar(50) not null,   password varchar(50) not null,  foreign key(password) references login(password),   foreign key(username) references   login(username) ); 

it seems relevant include password because needs not null field when inserting data. table user might have integer storing roles or similar tried simplify bit example.

i getting following error:

error 1005 (hy000): can't create table 'databasename.user' (errno:150)  error 150 type mismatch appear same type - not null , varchar(50) 

foreign key can point unique field.... primary key fields implicitly unique. password not.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -