arrow
arrow
arrow
Consider the following SQL commands and their corresponding relational algebra expressions. Identify which of the given options is correct. 1.
Question



Consider the following SQL commands and their corresponding relational algebra expressions. Identify which of the given options is correct.
1. SQL Command:
SELECT *
FROM Students S
JOIN Enrollments E ON S.StudentID = E.StudentID;
Relational Algebra:

2. SQL Command:
SELECT S.StudentName, E.CourseID
FROM Students S
JOIN Enrollments E ON S.StudentID = E.StudentID
WHERE E.CourseID = 'CS101';
Relational Algebra:

3. SQL Command:
SELECT S.StudentName
FROM Students S
LEFT JOIN Enrollments E ON S.StudentID = E.StudentID;
Relational Algebra:
Which of the following options correctly matches the SQL commands with their relational algebra expressions?

A.

Only 1

B.

Only 2

C.

Both 1 and 2

D.

Both 2 and 3

E.

All 1, 2, and 3

Correct option is C

Let’s solve it. Given,
SQL Command 1:
· The SQL command performs an inner join between Students and Enrollments based on StudentID.
· Given Relational Algebra:

· Correct Relational Algebra:

· Correct as the selection condition after the Cartesian product effectively represents an inner join.
SQL Command 2:
· The SQL command selects StudentName and CourseID from joined Students and Enrollments, filtered where CourseID is 'CS101'.
· Given Relational Algebra:

· Correct Relational Algebra:

· Correct as it accurately translates the SQL join and selection operations.
SQL Command 3:
· The SQL command performs a left join between Students and Enrollments based on StudentID.
· Given Relational Algebra:

· Correct Relational Algebra:

· Incorrect as the given algebra does not properly represent a left outer join.
Key Points:
1. Relational Algebra Joins:
· Inner Join: ⋈
· Left Outer Join: (⟕)
· Cartesian Product: ×
2. SQL Commands and Relational Algebra:
· Correctly map SQL join operations to their equivalent relational algebra expressions.
· Ensure the use of appropriate symbols and operations.
3. Projection and Selection:
· Projection: π
· Selection: σ
Knowledge Booster:
1. Relational Algebra:
· A procedural query language that works with the relational model of data.
· It's the theoretical foundation for SQL and other relational databases.
2. SQL Joins:
· Joins are used to combine rows from two or more tables based on a related column between them.
· Understanding different types of joins (inner, outer, left, right) is crucial for effective database querying.

Free Tests

Free
Must Attempt
Video Solutions

RBI Assistant Pre 2026 Full Mock Test -01

languageIcon English
  • pdpQsnIcon100 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Asst Prelims 2026 : Quant Section Test 01

languageIcon English
  • pdpQsnIcon35 Questions
  • pdpsheetsIcon35 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Asst Prelims 2026 : Reasoning Section Test 01

languageIcon English
  • pdpQsnIcon35 Questions
  • pdpsheetsIcon35 Marks
  • timerIcon20 Mins
languageIcon English
test-prime-package

Access ‘IBPS SO IT Officer’ Mock Tests with

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