Relational Algebra Expression. In the following questions, the schemas are provided. Please try to understand the schemas first and write the relational algebra expression for each of the following queries. Question 1: S(S#, SNAME, STATUS, CITY) //Supplier relation P(P#, PNAME, COLOR, WEIGHT, CITY) //Part relation J(J#, JNAME, CITY) //Job relation SPJ(S#, P#, J#, QTY) //Suppliers of Parts for Jobs relation 1. Find all suppliers with status ”30” that supply part ”P2”. For each supplier, output the name and the quantity of part ”P2” they supply. 2. Find and output the supplier numbers for all suppliers who either supply a ”Blue” part or supply to a job in ”Athens.” Question 2 Person ( PID, PersonName, Sex, Cityofbirth ) Parent ( ParentID, ChildID ) // both ParentID and ChildID are foreign keys referring to Person.PID a. Find the name of grandparents of all people who were born in New York city. b. Find the name of all people who were born in the same city as their father. Question 3: Student( SID, Sname, Curriculum ) Takes ( CourseID, SID, Semester, Grade ) //Semester is of the form ”Fall 98”, ”Spring 99”, etc. Write the following queries in relational algebra using only selection, projection, join, cartesian product, set union, intersection and difference. a. Find the id of all students who took the same course in two different semesters. b. Find the name of all students who never got an F. Question 4 School Database: STUDENT( sid, lastname, firstname, major, entrydate ) COURSE( course_number, dept_id, course_name) DEPARTMENT( dept_id, department_name, address ) INSTRUCTOR( instructor_id, firstname,lastname, dept_id ) SECTION ( section id, section_number, course_number, dept_id, semester, instructor_id ) TRANSCRIPT( sid, section_id, grade ) REQUIREMENT( req_id, major, course_number, dept_id ) 1. Find the last name, first name and major of all students taking any section of the course ”4380” offered by the ”Computer Science” department in ”Fall 99”. 2. Find the first name and last name of all instructors who taught the course ”4380” offered by the ”Computer Science” department. 3. Find the number and department identifier of all courses in which no student ever got an ”F”. 4. Find the identifier of all instructors who are teaching at least three sections of a course in the same semester. 5. Find the identifier of all students who took all the required courses for their majors -even if they do not have a grade for some of the courses yet. 5.1 Π Π person_name Employee) company_name=company_name Company))) person_name( σ city=Boston(( person_name=person_name 5.2 Πstreet (Employee ÷ Πperson_name(σcity=Boston(Company))) 5.3 Πmanager_name(σsalary>10000(Manages 5.4 Πperson_name,city(σsalary>10000(Employee manager_name=person_name Works)) person_name=person_name Works)) (Works
© Copyright 2026 Paperzz