170 likes | 417 Views
The Student Database. The Selection Operator . Give me information of students under the age of 18 age<18 (Student). The Projection Operator . Give me the name, address, and GPA of all the students name, addr, GPA (Student) name, GPA, addr (Student) . Sample Query.
E N D
The Selection Operator • Give me information of students under the age of 18 • age<18(Student)
The Projection Operator • Give me the name, address, and GPA of all the students • name, addr, GPA(Student) • name, GPA, addr(Student)
Sample Query • Give me the SID and GPA for students under the age of 18 • sid, GPA(age<18(Student))
The Cross Product Operator • Give me all combinations of students and the enrollment of students • Student Enroll = (Student.sid, name, addr, age, GPA, Enroll.sid, dept, cnum, sec)
Selecting on Cross Products • Give me all the information of enrolled students • Student.sid = Enroll.sid(Student Enroll)
Sample Query • Give me the name and addresses of students taking CS courses whose GPA is below 3.0 • name, addr(dept = ‘CS’ GPA < 3.0 Student.sid = Enroll.sid(Student Enroll))
The Join Operator • Class Enroll • Class.dept = Enroll.dept Class.cnum = Enroll.cnum Class.sec = Enroll.sec(Class Enroll)
The Theta-Join Operator • Class Class.cnum = Enroll.cnum Enroll.dept = ‘CS’ Enroll • Class.cnum = Enroll.cnum Enroll.dept = ‘CS’(Student Enroll)
The Union Operator • Give me the SIDs of all students • sid(Student GradStudent)
The Set-Difference Operator – • Give me the department, course number, and section of all classes without any enrolled students • dept, cnum, sec(Class) – dept, cnum, sec(Enroll)
The Set-Intersection Operator • Give all the instructors who teaches both CS and EE classes • instructor(dept=’CS’(Class)) instructor(dept=’EE’(Class))
The Rename Operator • Give me pairs of student names who live at the same address • R.name > S.name(name, name(R.addr = S.addr(R(Student) S(Student) ) ) )
The Division Operator / • Give me the SIDs of students who are enrolled in all of the CS classes • sid(Student) – sid(sid(Student dept, cnum, sec(dept=’CS’(Class))) – Enroll)
The Division Operator / • Give me the SIDs of students who are enrolled in all of the CS classes • sid(Student) – sid( sid(Student) dept, cnum, sec(dept=’CS’(Class)) – Enroll) )