baidu_40582876
学习中的青年
2018-04-18 06:48

关于mysql的问题求指教

5
  • 代码
  • mysql
  • 外键约束

create table tb_user
(
user_id int(100) not null auto_increment,
user_name varchar(200) not null default'',
user_password varchar(1000)not null,
user_phone varchar(1000),
user_typeint(10)not null,
user_emailvarchar(2000) not null,
user_imgvarchar(2000) default null,
create_time datetime default null,
last_edit_time datetime default null,
primary key(user_id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

create table tb_lost
(
lost_idint(100)not null auto_increment,
lost_typevarchar(2000) not null,
lost_placevarchar(2000)not null,
lost_user_idint(100)not null,
lost_user_namevarchar(2000)not null,
lost_phonevarchar(1000) not null,
lost_time varchar(2000) not null,
take_time varchar(2000) not null,
lost_img varchar(2000) not null,
primary key(lost_id),
constraint fk_lostuser_idforeign key(lost_user_id) references tb_user(user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

create table tb_pick
(
pick_idint(100)not null auto_increment,
pick_typevarchar(2000) not null,
pick_placevarchar(2000)not null,
pick_user_idint(100)not null,
pick_user_namevarchar(2000)not null,
pick_phonevarchar(1000) not null,
pick_time varchar(2000) not null,
take_time varchar(2000) not null,
pick_img varchar(2000) not null,
primary key(pick_id),
constraint fk_pcikuser_idforeign key(pick_user_id) references tb_user(user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

create table ly_info
(
ly_info_idint(100)not null auto_increment,
ly_user_idint(100)not null,
ly_txtvarchar(2000)not null,
ly_timevarchar(2000)not null,
primary key(ly_info_id),
constraint fk_ly_idforeign key(ly_user_id) referencestb_user(user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

create table hf_info
(
hf_idint(100)not null auto_increment,
hf_info_idint(100)not null,
hf_user_idint(100)not null,
hf_txtvarchar(2000)not null,
hf_timevarchar(2000)not null,
primary key(hf_info_id),
constraint hf_info_id foreign key(ly_info_id)referencesly_info(hf_info_id),
constraintfk_hf_id foreign key(hf_user_id)referencestb_user(hf_user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

create table gg_info
(
gg_idint(100)not null auto_increment,
gg_txtvarchar(2000)not null,
gg_timedatetime not null,
primary key(gg_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
第四张表的约束外键约束有问题,为什么

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答