Use the following query to compute a new table.
section_and_time = π course_id, sec_id, semester, year, day, start_hr, start_min, end_hr, end_min (section ⨝ time_slot)Using only section_and_time, write a relational algebra expression that returns a relation of overlapping courses of the form
(course_id_1, sec_id_1, semester_1, year_1, course_id_2, sec_id_2, semester_2, year_2)Your table cannot contain duplicates. For example, a result containing
(BIO-101, 1, fall, 2022, MATH-101, 2, fall, 2022) (MATH-101, 2, fall, 2022, BIO-101, 1, fall, 2022)is incorrect.
I've tried the following SQL query:
SELECT S1.course_id, S1.sec_id, S1.semester, S1.year, S2.course_id, S2.sec_id, S2.semester, S2.year
FROM section_and_time S1, section_and_time S2
WHERE (S1.course_id != S2.course_id)
AND NOT (S1.end_hr < S2.start_hr AND S1.end_min < S2.start_min)
But the joining of two section_and_time tables causes the joining to occur with every column. How can I do it so that 1 course_id will join with every course_id in the table?