以oracle 为例:
1、create table student( Sno number(10) primary key,
Sname varchar2(20),
Ssex varchar2(2),
Sage number(10),
Sdept varchar2(20)
);
2、SELECT FROM student FROM Sdept='计算机' ORDER BY Sno DESC
3、SELECT DISTINCT studentSno,studentSname,studentSsex
FROM student,Course,SC
where studentSno=SCSno AND CourseCno=SCCno
AND CourseCcredit=5 AND SCGrade > 60
4、create or replace trigger my_trig
after delete on student
for each row
begin
delete from SC where Sno=:studentSno;
end;
--1
select Sname,Sage from Student where Sage<(select Sage from Student where Sno='某一学生') and Sdept='数学系'
--2
select Sname from Student where Sno in (select Sno from SC)
--3
select Sname from Student where Sno in (select Sno from SC group by Sno having count()=(select count() from Course ))
--4
题意不清楚
1)SELECT ssno, scgrade
FROM (s INNER JOIN sc ON ssno = scsno) INNER JOIN c ON sccno = ccno
WHERE (((ccno)="c2"));
2)SELECT ssno, ssname
FROM (s INNER JOIN sc ON ssno = scsno) INNER JOIN c ON sccno = ccno
WHERE (((ccno)="c2"));
3)SELECT ssno, ssname
FROM (s INNER JOIN sc ON ssno = scsno) INNER JOIN c ON sccno = ccno
WHERE (((ccname)="maths"));
4)SELECT ssno
FROM (s INNER JOIN sc ON ssno = scsno) INNER JOIN c ON sccno = ccno
WHERE (((ccno)="c2")) OR (((ccno)="c4"));
5)SELECT ssname, ssag
FROM (s INNER JOIN sc ON ssno = scsno) INNER JOIN c ON sccno = ccno
WHERE (((ccno)<>"c2"));
关于反映这三张表中数据之间的联系,提供三方面信息以供参考:
1、表关系分析:学生表与课程表是多对多的关系,建立一张关联表也就是选课表来将学生表与程表产生关联。
2、数据库表分析:学生表包括学生相关信息,课程表包括课程相关信息,选课表放其他两张表的各一个字段(可以维护唯一性,比如说主键)。
3、实体分析:包含学生和课程两个实体,在每个实体中加入另外一个实体的集合。
1>select sno,sname from Student where sdept='IS'
2>select SNO,GRADE from SC where SNO=1
3>select SCGRADE ,CCName from SC , C where SCSNO=990101 and SCCNO=CCNO
4>select Studentsname SCSNO SCCNO from Student inner join SC on StuentSNO=SCSNO where SCGRADE >95
5>select Studentsname ,SCGRADE from Student inner join SC on StuentSNO=SCSNO where SCCNO=(select CNO from C where CNAME='ACCESS') order by SCGREDE dec
6> select sno ,sname ,sdept from Student where sname like '王%'
有错的地方请指点!
以上就是关于有一个“学生-课程”数据库,数据库中包括三个表:全部的内容,包括:有一个“学生-课程”数据库,数据库中包括三个表:、假设“学生—课程”数据库中包含学生表、课程表、学生选课表3个表、设教学数据库有四个关系模式学生关系S(sno,sname)课程关系C(cno,cname)教师关系学等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)