ago edited ago by
54 views
1 1 vote

Consider the relations:

$\mathrm{STUDENT(name,regno,gpa,level,dept)}$

$\mathrm{COURSE(cno,cname,dept)}$

$\mathrm{TAKE(regno,cno)}$

Using only the basic relational algebra operators, which expression returns the names of students taking at least one course offered by the $\mathrm{EECS}$ department?

  1. $\pi_{\mathrm{name}}\bigl($ $\sigma_{\mathrm{STUDENT.regno=TAKE.regno}\ \land\ \mathrm{TAKE.cno=COURSE.cno}\ \land\ \mathrm{COURSE.dept='EECS'}}$ $\bigl(\mathrm{STUDENT}\times\mathrm{TAKE}\times\mathrm{COURSE}\bigr)$ $\bigr)$
     
  2. $\pi_{\mathrm{name}}(\sigma_{\mathrm{STUDENT.dept='EECS'}}(\mathrm{STUDENT}))$
     
  3. $\pi_{\mathrm{name}}(\sigma_{\mathrm{COURSE.dept='EECS'}}(\mathrm{STUDENT}\times\mathrm{COURSE}))$
     
  4. $\pi_{\mathrm{name}}\bigl($ $\sigma_{\mathrm{STUDENT.regno=TAKE.regno}\ \land\ \mathrm{COURSE.dept='EECS'}}$ $\bigl(\mathrm{STUDENT}\times\mathrm{TAKE}\times\mathrm{COURSE}\bigr)$ $\bigr)$

1 Answer

1 1 vote

Three pieces of information must be connected.

A student participates in $\mathrm{TAKE}$ through

$\mathrm{STUDENT.regno = TAKE.regno}$.

A $\mathrm{TAKE}$ tuple identifies the course through

$\mathrm{TAKE.cno = COURSE.cno}$.

Finally, the course must satisfy $\mathrm{COURSE.dept} =$ '$\text{EECS}$'.

Therefore, form the Cartesian product:

$\mathrm{STUDENT \times TAKE \times COURSE}$

and select only those tuples satisfying all three conditions:

$\mathrm{STUDENT.regno = TAKE.regno}$

$\mathrm{TAKE.cno = COURSE.cno}$

$\mathrm{COURSE.dept} =$ '$\text{EECS}$'.

Finally, project $\mathrm{name}$.

Thus, A is correct.

B finds students whose own department is $\mathrm{EECS}$. That is a different question.

C never connects students to courses through $\mathrm{TAKE}$, so every student could be paired with an $\mathrm{EECS}$ course.

D connects a student to a $\mathrm{TAKE}$ record, but never connects that $\mathrm{TAKE}$ record to the selected $\mathrm{EECS}$ course. It can therefore generate false matches.

Hence, the correct expression is A.

ago
Answer:
Position:
Show:

Related questions

1 1 vote
2 2 answers
113
113 views
GO Classes asked 1 day ago
113 views
Consider the relations:$\mathrm{Users(username, name, email, password, address)}$and$\mathrm{FriendsWith(username, username2, sincewhen)}$.A friendship tuple indicates th...
1 1 vote
1 1 answer
51
51 views
GO Classes asked 1 day ago
51 views
Consider $R(a,b)$ and $S(c,d)$.Which relational algebra expression is equivalent to:SELECT a, d FROM R, S WHERE R.a 10 AND R.b = S.c;Use only the basic operators.$\pi_{a...
1 1 vote
1 1 answer
47
47 views
GO Classes asked 1 day ago
47 views
Let $R$ and $S$ be union-compatible relations.Which expression computes $R\cap S$ using only union and set difference?$(R\cup S)-((R-S)\cup(S-R))$ $(R\cup S)-(R-S)$ $(R-S...
1 1 vote
1 1 answer
60
60 views
GO Classes asked 1 day ago
60 views
Consider $\text{parts(pno, pname, price)}$.Which relational algebra expression returns exactly the names of all parts whose price is greater than $\$200$?$\pi_{\text{pnam...