Skip to content
Worked Examples · Example 1.7

Q.Using the DANCE and MUSIC relations to understand how two relations are used together in a query:

(a) Display all possible combinations of tuples of the relations DANCE and MUSIC (the Cartesian product). State the degree and cardinality of the resulting table.
(b) From all possible combinations of tuples of DANCE and MUSIC, display only those rows where the attribute Name in both relations has the same value (use table aliases D for DANCE and M for MUSIC).
Tamil Nadu DgeTextbookSubjective· 3mImportance★★★★★
33% · 13/40 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Concept understanding — Relational Algebra Operations

Relational Algebra Operations: A First Look

Think of a relational database as a collection of neat, rectangular tables. Each table has rows (records) and columns (attributes). Now, suppose you want to ask questions of this data — "Which customers live in Delhi?" or "Show me all orders placed last month." Relational algebra is the set of basic operations you use to answer such questions. It is the language of queries at the most fundamental level.

You do not need to write code or do math. You only need to understand what each operation does to a table — like a set of tools in a toolbox.


The Core Operations

There are eight classic operations. They fall into two groups: those that work on one table at a time, and those that combine two tables.

Operations on a Single Table

Select (also called Restrict) — This operation picks certain rows from a table based on a condition. For example, from a table of students, you might select only those rows where the city is "Mumbai". The result is a smaller table with the same columns but fewer rows.

Project — This operation picks certain columns from a table. For example, from a student table with columns Roll No, Name, City, and Marks, you might project only Name and City. The result is a table with fewer columns. Duplicate rows are automatically removed.

Rename — This operation simply gives a new name to the resulting table or to its columns. It is useful when you need to refer to the same table more than once in a query, or when you want clearer column headings.

Note

Select and Project are the two most frequently used operations. Select narrows down rows; Project narrows down columns. Together they let you extract exactly the slice of data you need.

Operations That Combine Two Tables

Union — This combines two tables that have the same structure (same number of columns and compatible data types). The result contains all rows that appear in either table, with duplicates removed. Think of it as "add the rows of one table to the rows of another, but keep only unique ones."

Set Difference — This gives you rows that are in the first table but not in the second. For example, "Which students are enrolled in Course A but not in Course B?"

Intersection — This gives you rows that appear in both tables. For example, "Which customers have bought both a laptop and a printer?"

Cartesian Product — This pairs every row of the first table with every row of the second table. If the first table has 10 rows and the second has 5, the result has 50 rows. This operation is rarely used alone — it is the foundation for the most powerful operation of all.

Join — This is the heart of relational algebra. A join combines rows from two tables based on a related column between them. For example, you have a Customers table and an Orders table. The join operation matches each order to the customer who placed it, using the Customer ID column that appears in both tables. The result is a single table with all the customer details alongside their orders.

Important

The Join operation is what makes relational databases relational. Without it, data in separate tables would remain isolated. Joins let you connect information across tables — customers to orders, students to courses, products to suppliers — and answer questions that span multiple pieces of data.


Why Relational Algebra Matters …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.