arrow
arrow
arrow
Which of the following relational algebraic expression is equivalent to the SQL query SELECT X FROM B WHERE Y?
Question

Which of the following relational algebraic expression is equivalent to the SQL query SELECT X FROM B WHERE Y?

A.

σy(πx(B))\sigma_y(\pi_x(B))​​

B.

πy(σx(B))\pi_y(\sigma_x(B))​​

C.

σx(πx(B))\sigma_x(\pi_x(B))​​

D.

πx(σy(B))\pi_x(\sigma_y(B))​​

Correct option is D

The SQL query is:
SELECT X
FROM B
WHERE Y;
We need to translate this SQL query into relational algebra.
Step 1: Understand the WHERE clause
The WHERE Y condition filters the rows of relation B based on condition Y.
In relational algebra, selection is represented by: σ\sigma​​
Therefore, σY(B)\sigma_Y(B)​ means select those tuples from B that satisfy condition Y.
Step 2: Understand the SELECT X clause
The SQL statement:
SELECT X
means that after filtering, we want only attribute X.
In relational algebra, projection is represented by: π
Therefore, πX(σY(B))\pi_X(\sigma_Y(B))​ means:
1. First select the tuples satisfying Y.
2. Then project attribute X.
Thus:
πX(σY(B))\boxed{\pi_X(\sigma_Y(B))}​​
Information Booster
1. Selection (σ)(\sigma) → selects rows/tuples satisfying a condition.
2. Projection (π)(\pi) → selects columns/attributes.
3. SQL WHERE corresponds primarily to selection.
4. SQL SELECT of specific attributes corresponds to projection.
5. The usual order for this query is:
Selection first, then Projection\boxed{\text{Selection first, then Projection}}​​
Additional Knowledge
The options can be eliminated as follows:
· (a) σY(πX(B))\sigma_Y(\pi_X(B))​ — projection is performed before applying the condition; generally not equivalent.
· (b) πY(σX(B))\pi_Y(\sigma_X(B))​ — selection and projection attributes are reversed.
· (c) σX(πX(B))\sigma_X(\pi_X(B))​ — uses X as the selection condition rather than Y.

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English

Similar Questions

TEST PRIME

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
1 month
students-icon
527k+ students have already unlocked exclusive benefits with Test Prime!

Similar Questions

Our Plans
Monthsup-arrow