MySQL一对一操作
MySQL一对一操作
用户表和博客表
用户表(userinfo):
用户id 用户名
1 George
2 root
3 Bruce
4 Catherine
博客表:
博客id 博客名 用户id(FK + 唯一)
1 /adfadsfdfasd/ 4
2 /qwerr/ 1
3 /asdfa/ 3
4 /ffffffff/ 2
create table userinfo1(id int auto_increment primary key,
name char(10),
gender char(10),
email varchar(64)
)engine=innodb default charset=utf8;
create table admin(id int not null auto_increment primary key,
username varchar(64) not null,
password VARCHAR(64) not null,
user_id int not null,
unique uq_u1 (user_id),
constraint fk_admin_u1 foreign key (user_id) references userinfo1(id)
)engine=innodb default charset=utf8;
------ END ------