alter table t_book add constraint `fk` foreign key (`bookTypeId`) references t_booktype(`id`);
或者在創表時直接加上
CREATE TABLE t_book(
id int primary key auto_increment,
bookName varchar(20),
author varchar(10),
price decimal(6,2),
bookTypeId int,
constraint `fk` foreign key (`bookTypeId`) references `t_bookType`(`id`)
);