554 views
Consider the following relations:

$\text{STD_CHOICES } (\underline{\text{Student_ID}}, \underline{\text{Course_ID}}, \text{Semester})$ and

$\text{COURSE_ASSIGN} (\underline{\text{Teacher_ID}}, \underline{\text{Course_ID}}, \underline{\text{Semester}})$.

The former indicates the choice of courses for students and the latter indicates the course assigned to teachers for different semesters. Note that each student may take multiple courses, each teacher can teach multiple courses and each course can also be taught by multiple teachers. Write the relational calculus expression to output the ID for all the students who have not been taught by the same teacher in more than one course across all semesters.

### 1 comment

$$\{ \text{ t | } \exists S1 \in \text{Std_choice}, \exists C1 \in \text{Course_Assign} (S1.Course_{\_}ID = C1.Course_{\_}ID ) \land \\\ \exists S2 \in \text{Std_choice}, \exists C2 \in \text{Course_Assign} (S2.Course_{\_}ID = C2.Course_{\_}ID ) \land \\\ (S1.Student_{\_}ID = S2.Student_{\_}ID \land C1.Course_{\_}ID \ne C2.Course_{\_}ID \land C1.Semester = C2.Semester \land S1[Student_{\_}ID] = t)\}$$

1 vote