CREATE TABLE STUDENT(
SID CHAR(4),
NAME VARCHAR(20) NOT NULL,
EMAIL VARCHAR(20),
PHONE VARCHAR(10),
PRIMARY KEY(SID)
);
CREATE TABLE CLUB(
CID CHAR(4),
CNAME VARCHAR(50) NOT NULL,
PRIMARY KEY(CID)
);
CREATE TABLE EVENT(
EID CHAR(4),
ENAME VARCHAR(50),
EDATE TIMESTAMP,
PRIMARY KEY(EID)
);
CREATE TABLE MEMBERSHIP(
SID CHAR(4),
CID CHAR(4),
SEMESTER VARCHAR(10),
MYEAR CHAR(4),
FEE DECIMAL(5,2),
FOREIGN KEY(SID) REFERENCES STUDENT(SID),
FOREIGN KEY(CID) REFERENCES CLUB(CID),
PRIMARY KEY(SID,CID,SEMESTER,MYEAR)
);
CREATE TABLE HOLDEVENT(
EID CHAR(4),
CID CHAR(4),
MEMFEE DECIMAL(5,2),
NONMEMFEE DECIMAL(5,2),
FOREIGN KEY(EID) REFERENCES EVENT(EID),
FOREIGN KEY(CID) REFERENCES CLUB(CID),
PRIMARY KEY(EID,CID)
);
CREATE TABLE JOINEVENT(
EID CHAR(4),
SID CHAR(4),
FEE DECIMAL(5,2),
FOREIGN KEY(EID) REFERENCES EVENT(EID),
FOREIGN KEY(SID) REFERENCES STUDENT(SID),
PRIMARY KEY(EID,SID)
);
如何编写以下查询:
- 输出一起组织超过 5 场赛事的所有俱乐部对的名称?
- 输出自 1990 年秋季以来在每个学期加入 XYZ 的任何学生的 sid?
With temp(sem,tyear) as (select semester,n from (select unique semester from Membership),(select n from( select rownum n from dual connect by level <= Extract(year from sysdate)) where n >= 1990))
select distinct sid from Membership M1 WHERE NOT EXISTS
(select * from temp WHERE NOT EXISTS
(select * from Membership M2 WHERE M1.sid = M2.sid AND M2.myear=temp.tyear AND M2.semester=temp.sem AND M2.cid in (select cid from Club where cname='Chess Club')));
请帮助识别此架构中的弱实体。