create table employees (
id int(5) not null auto_increment ,
name varchar(8) not null,
primary key (id)
)
type=innodb;
create table payroll(
id int(5) not null,
emp_id int(5) not null,
payroll float(4,2) not null,
primary key(id),
index emp_id (emp_id),
foreign key (emp_id) references employees (id)
type = innodb;
表間一對多關系示例:
本文轉自 小強測試幫 51CTO部落格,原文連結:http://blog.51cto.com/xqtesting/808468,如需轉載請自行聯系原作者