我的查询是:(查找在 115 房间开会或有五个或更多学生注册的所有班级的名称。)
CREATE TABLE STUDENT (
sid NUMERIC(6) NOT NULL,
sname VARCHAR(15),
major VARCHAR(20),
level VARCHAR(2),
sage NUMERIC(2) NOT NULL,
PRIMARY KEY (sid)
);
CREATE TABLE CLASS(
cnum VARCHAR(6),
meets_at TIME,
room VARCHAR(6),
fid NUMERIC(6) ,
PRIMARY KEY (cnum),
FOREIGN KEY (fid)
references FACULTY (fid)
);
CREATE TABLE ENROLLED (
cnum VARCHAR(6),
sid NUMERIC(6) NOT NULL,
PRIMARY KEY (cnum,sid),
FOREIGN KEY (sid)
REFERENCES STUDENT (sid),
FOREIGN KEY (sid)
REFERENCES FACULTY (fid),
FOREIGN KEY (cnum)
REFERENCES CLASS (cnum)
);
alter table ENROLLED
add foreign key (sid)
references STUDENT (sid);