【数据库系统概论】关系演算基础

语句格式:
操作语句 工作空间名 (表达式1) :操作条件 [ DOWN | UP 表达式2]

查询所有被选修的课程号码
GET W (SC.Sno) W的意思是把SC的Sno 放在 W空间中 , 工作空间名随便

查询所有学生的数据
GET Z (Student) 不写字段默认表的区别数据

[限定的检索(带条件的检索)]

查询信息系(IS)中年龄小于20岁的学号和年龄
GET S (Student.Sno,Student.Sage) : student.sdept = ‘IS’ ^ Student.Sage<20

查询系名为IS中男生并且年龄是19岁的 姓名和学号 (冒号后面加条件)

GET V (Student.Sname , Student.Sno) : student.sdept = ‘IS’ ^ student.Ssex =’男’ ^ Student.Sage<19.

[带排序的检索]

查询计算机科学系(CS) 学生的学号,年龄,并按年龄降序排序
GET S(Student.Sno,Student.Sage) : student.sdept = ‘Cs’ DOWN Student.Sage

[返回元组的条数的检索]

取出一个信息系学生的学号
GET W (1) (Student.Sno) : Student.Sdept =’IS’ ( (1)这个就是定额取出一个 一般和排序使用 )

查询信息系年龄最大的三个学生的学号和及其年龄,结果按照年龄降序
GET S (3) (Student.Sno,Student.Sage): student.sdept = ‘Cs’ DOWN Student.Sage

[元组变量的检索 这个也称范围变量]
1.简化关系名 关系名太长就可以使用
RANGE student x

查询信息系年龄最大的三个学生的学号和及其年龄,结果按照年龄降序
GET S (3) (x.Sno,x.Sage): x.sdept = ‘is’ DOWN x.Sage

查询信息系学生的名字
Range student x
GET S (x.name): x.sdept = ‘is’
存在量词的检索
(有些 , 至少有 , 一个,有一个 等 表示个别部分 符号:反过来的E )

查询选修了2号课程的学生名字
Range SC x
GET W (student.Sname):E(student.Sno = x. Sno ^ X.Con =’2’)

(全额,每一个,任意,一切 一定范围 到过来的A 不敢保证存不存在的情况下使用 )

猜你喜欢

转载自blog.csdn.net/qq_46874327/article/details/125037509
今日推荐