字段修改表关系回顾

昨日回顾

1.字段修改
alter modify
alter change
alter add ''|first|after
alter drop

2.表关系
一对一:外键存在两边都可以
	一对多:外键存在多的一方
	多对多:外键必须存在第三张关系表
	外键:外键是表的一个字段,值可以重复也可以唯一,值是被关联表被关联字段的值,被关联字段必须有唯一键
    foreign key(外键字段) references 被关联表(被关联字段)
	
	create table book(
		id int not null primary key auto_increment,
		name varchar(64) unique
	);
	create table author(
		id int not null primary key auto_increment,
		name varchar(64) unique
	);
	create table book_author(
		id int not null primary key auto_increment,
		book_name varchar(64),
		author_name varchar(64),
		foreign key(book_name) references book(name)
		on update cascade
		on delete cascade,
		foreign key(author_name) references author(name)
		on update cascade
		on delete cascade
	);
原文地址:https://www.cnblogs.com/aden668/p/11585372.html