Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Consider the following relations:

Student (ssn, name, address, major)
Course (code, title)
Registered (ssn, code)
Use relational algebra to answer the following :
a. List the codes of courses in which at least one student is
registered (registered courses).
b. List the title of registered courses.
c. List the codes of courses for which no student is registered.
d. The titles of courses for which no student is registered.
e. Name of students and the titles of courses they registered to.
f. SSNs of students who are registered for both database systems
and analysis of algorithms.
g. SSNs of students who are registered for both database systems
and analysis of algorithms.
h. The name of students who are registered for both database
systems and analysis of algorithms.

i. List of courses in which all students are registered.
j. List of courses in which all ‘ECMP’ major students are registered.

a. List the codes of courses in which at least one student is registered (registered courses). �����(����������)πcode​(Registered)

b. List the title of registered courses. ������(������⋈����������)πtitle​(CourseRegistered)

c. List the codes of courses for which no student is registered. �����(������)−�����(����������)πcode​(Course)−πcode​(Registered)

d. The titles of courses for which no student is registered. ������(������−(������⋈����������))πtitle​(Course−(CourseRegistered))

e. Name of students and the titles of courses they registered to. �����,�����(�������⋈����������⋈������)πname,title​(StudentRegisteredCourse)

f. SSNs of students who are registered for both database systems and analysis of algorithms. g. SSNs of students who are registered for either database systems or analysis of algorithms. h. The name of students who are registered for both database systems and analysis of algorithms. �����(����((�������⋈����������⋈(������⋈������=′���������������′������))∩(�������⋈����������⋈������=′�����������������ℎ��′������))⋈�������)πname​(πssn​((StudentRegistered⋈(Courseσtitle=′Database Systems′​Course))∩(StudentRegisteredσtitle=′Analysis of Algorithms′​Course))⋈Student)

i. List of courses in which all students are registered. �����,���(����������)/����(�������)πcode,ssn​(Registered)/πssn​(Student)

j. List of courses in which all ‘ECMP’ major students are registered. �����,���(����������)/����(������=′����′�������)πcode,ssn​(Registered)/πssn​(σmajor=′ECMP′​Student)

Explanation:

  • �…π…​: Projection operation (selecting specific columns)
  • �…σ…​: Selection operation (filtering rows based on a condition)
  • ⋈⋈: Natural join operation (joining tables based on common columns)
  • �/�A/B: Division operation (returning elements from A that match every element in B)

These expressions represent the operations needed to answer each question using relational algebra.

Leave a Comment