资源描述
6. I 7.使用大学的模式, 用关系代数来表达下面这些查询。A. 找出计算机( Comp. Sci. )系开设的占3 个学分的课程的名称。b 找出选了教师Einstei n 所教课程的所有学生的ID , 注意结果中不能有重复。c. 找出所有教师的最高工资。d. 找出收入为最高工资的所有教师(可能有多个人工资相同) 0e. 找出29 年秋季学期开设的各个课程段的选课人数。L 找出29 年秋季学期开设的各个课程段中最大的选课人数。g. 找出在29 年秋季学期选课人数最多的课程段。a. 5ti tle (sdept name = Comp. Sci credits=3(course)b. 5I D(sI I D = Einstein(takes 1 rt1(IID, course id, section id, semester, year)teaches)Assuming the set version of the relational algebra is used, there isno need to explicitly remove duplicates. If the multiset version isused, the grouping operator can be used without any agggregationto remove duplicates. For example given relation r (A, B) possiblycontaining duplicates, A,BG(r ) would return a duplicate free versionof the relation.c. Gmax(salary)(instructor)d. instructor 1 (Gmax(salary) as salary (instructor)Note that the above query renames the maximum salary as salary, sothe subsequent natural join outputs only instructors with that salary.e. course id,section idGcount() as enrollment(syear=2009semester=Autumn(takes)f. t1 course id,section idGcount() as enrollment(syear=2009semester=Autumn(takes)result = Gmax(enrollment)(t1)g. t2 Gmax(enrollment) as enrollment(t1)where t1 is as defined in the previous part of the question.result = t1 1 t2
展开阅读全文