学生表(t_ student),字段有id, name,age,gender, cid.
-- 班级表
create table t_class(
id int(3) primary key auto_increment,
name varchar(20) not null,
room varchar(30)
);
-- 学生表
create table t_student(
id int(5) primary key auto_increment,
name varchar(30) not null,
age int(3),
gender char(3),
cid int (3) references t_class(id)
);
-- 测试数据
insert into t_class values
(default ,'java','001' ),
(default ,'python','002' ),
(default ,'PHP','003' ),
(default ,'UI','004' );
insert into t_student values
(default,'小明',18,'男',1),
(default,'小周',19,'女',3),
(default,'小黄',20,'女',1),
(default,'小洪',21,'女',1),
(default,'小亮',16,'男',2),
(default,'小鹏',15,'男',3);
select * from t_class;
select * from t_student;