多对多的关系必须另外添加一张表来表示
--班级 create table banji ( banji_id int constraint PK_banji primary key, --主键 banji_num int not null, banji_name nvarchar(20) ) --教师 create table jiaoshi ( jiaoshi_id int constraint PK_jaioshi primary key, --主键 jiaoshi_name nvarchar(20) not null ) --班级和教师的关系 create table banji_jiaoshi_mapping ( banji_id int constraint FK_bnaji_id foreign key references banji(banji_id), --外键 jiaoshi_id int constraint FK_jaoshi_id foreign key references jiaoshi(jiaoshi_id), --外键 kecheng nvarchar(20), constraint PK_banji_id_jiaoshi_id primary key (banji_id, jiaoshi_id, kecheng) --benji_id, jiaoshi_id, kecheng的三者组合作为主键 )
数据库关系图: