Skip to main content

Chapter 3 · Watch, then practise

Relational Languages & Relational Model

Connect relational algebra to SQL by filtering rows, choosing columns and joining related tables.

3 questions · 3 with related videos. Matches are based on playlist titles; broader background matches are labeled.

What to study

  • Selection and projection
  • Cartesian product and join
  • SQL joins
  • Set semantics and duplicate rows

Chapter playlists

Choose a playlist

Notes

Lec-52: Selection in Relational Algebra | Database Management System

Gate Smashers · 6:33

Choose a video · 2 lectures

Supplementary lectures distinguish relational selection and projection, the two operators in this question.

1. Selection and projection

For Student(id, name, semester), how do selection and projection differ?

Selection keeps rows satisfying a condition, such as semester = 6. Projection keeps named attributes, such as name. Combining them gives names of sixth-semester students. Classical relational algebra uses sets, so projection removes duplicates; SQL needs DISTINCT when duplicate output rows should be removed.

Lec-46: Equi Join operation with Example | Database Management System

Gate Smashers · 14:15

Equi-join examples support matching student rows to enrollment rows by the shared identifier.

2. Join reasoning

What does an inner join between Student and Enrollment return?

It pairs rows satisfying the join condition, usually Student.id = Enrollment.student_id. One student with three enrollments produces three matching pairs. A student with none produces no row. A left join preserves that student, with NULLs for the absent enrollment fields.

L94: Solved Question(1) on SQL Queries - Employee, Works, Company, Manages Relation Queries

Easy Engineering Classes · 5:00

Choose a video · 2 lectures

Worked SQL and equi-join examples support writing the query; their example tables differ from Student and Enrollment.

3. Write a query

Write SQL to return names of students enrolled in course DB6.

SELECT DISTINCT s.name FROM Student AS s JOIN Enrollment AS e ON e.student_id = s.id WHERE e.course_id = 'DB6';

The join connects enrollment records to students; WHERE selects the course; DISTINCT removes repeated names. Return s.id too when different students may share a name.

References