edited by
7,932 views
30 votes
30 votes

Consider the following relational database schemes:

  • COURSES (Cno, Name)
  • PRE_REQ(Cno, Pre_Cno)
  • COMPLETED (Student_no, Cno)

COURSES gives the number and name of all the available courses.

PRE_REQ gives the information about which courses are pre-requisites for a given course.

COMPLETED indicates what courses have been completed by students

Express the following using relational algebra:

List all the courses for which a student with Student_no 2310 has completed all the pre-requisites.

edited by

10 Answers

4 votes
4 votes

I came up with two approach for this Question.

Note- Questions in which "ALL" keyword is used, most probably would be solved with division operation.  

1 votes
1 votes
SELECT Cno

FROM Courses C1

WHERE NOT EXIST ( ( SELECT Pre-cno

                                      FROM PRE-REQ P1

                                      WHERE C1.Cno=P1.Cno

                                      EXCEPT

                                      SELECT Cno

                                      FROM COMPLETED C2

                                      WHERE C2.student_no='2310' ) ) ;

Is this query correct ?
reshown by
0 votes
0 votes

This should be the answer.

ΠCno(PRE-REQ) - ΠCno(PRE-REQ - ρPRE-REQ.Cno/CnoPRE-REQ.Cno,pre-Cno((σstudent_no=2310 (COMPLETED))⋈Cno=pre-Cno PRE-REQ)))

edited by

Related questions

23 votes
23 votes
1 answer
1
Kathleen asked Sep 25, 2014
7,165 views
Given two union compatible relations $R_1(A, B)$ and $R_2 (C, D)$, what is the result of the operation $R_1 \Join_{ A = C \wedge B = D} R_2$?$R_1 \cup R_2$$R_1 \times R_2...
47 votes
47 votes
2 answers
4
Kathleen asked Sep 25, 2014
9,755 views
There are five records in a database.$$\begin{array}{|c|c|c|c|} \hline \textbf {Name} & \textbf {Age} & \textbf {Occupation} & \textbf{Category } \\\hline \text{Rama} & ...