Many-to-many relationships must be added with a separate table to represent
--Class CREATE TABLE Banji (banji_id int constraint Pk_banji primary key, --primary key banji_num int not null,banji_name nvarchar (2 0)--Teacher CREATE TABLE Jiaoshi (jiaoshi_id int constraint Pk_jaioshi primary key, --primary key jiaoshi_name nvarchar () NOT NULL )--the relationship between class and teacher create TABLE banji_jiaoshi_mapping (banji_id int constraint fk_bnaji_id foreign key references Banji (banji_id ), --FOREIGN key jiaoshi_id int constraint fk_jaoshi_id foreign key references Jiaoshi (jiaoshi_id), --foreign key Kecheng nvarchar (a), constraint pk_banji_id_jiaoshi_id primary key (banji_id, jiaoshi_id, Kecheng) --benji_id, jiaoshi_id, Kecheng three-group co-operation as the primary key)
Database diagram:
Implementation of many-to-many relationships in SQL Server