Q.(a) Consider the following tables - LOAN and BORROWER: Table: LOAN LOAN_NO B_NAME AMOUNT L-170 DELHI 3000 L-230 KANPUR 4000 Table: BORROWER CUST_NAME LOAN_NO JOHN L-171 KRISH L-230 RAVYA L-170 How many rows and columns will be there in the natural join of these two tables?
🔒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 →Part (a)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.
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.
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 …
Part (b)Concept understanding — Database Querying
Database Querying: Asking Questions of a Data Collection
Think of a library. You walk in, and instead of wandering through endless shelves, you go to the librarian and say: "I need all books by R. K. Narayan published after 1980." The librarian knows exactly where to look, finds the relevant books, and hands you a short list. That act of asking — of specifying exactly what you want from a large, organised collection — is the essence of querying.
A database is like that library, but for digital information. It stores data in a structured way, typically in tables with rows and columns. A query is simply a question you ask of that database. You don't need to know where the data lives or how it's stored internally. You just need to state what you want.
The Precise Meaning
In formal terms, a database query is a request for data or information from a database. The request is written in a special language that the database understands. The most common such language is SQL (Structured Query Language), but the concept of querying exists in every database system.
When you query a database, you are doing one of four things:
- Retrieving data (the most common — "show me the customers who live in Delhi")
- Inserting new data ("add this new student record")
- Updating existing data ("change this address")
- Deleting data ("remove this old order")
For a commerce or humanities student, the retrieval part is where the real power lies. You are not just pulling out raw data — you are filtering, sorting, and combining it to get answers.
Why It Matters
A database without querying is like a library with the lights off. The data exists, but you cannot use it. Querying turns stored facts into actionable information.
Consider a small business owner who keeps customer records in a spreadsheet. Without querying, they might scroll through hundreds of rows to find customers who haven't purchased in six months. With a query, they type one request and get the answer instantly. That answer might lead to a targeted marketing campaign, which brings in revenue.
Querying is not about memorising commands. It is about thinking in terms of conditions and relationships. The skill is learning to translate a real-world question — "Which products are out of stock?" — into a precise, unambiguous request the database can process.
The Intuition Behind It
Every query has a simple structure at its core:
- What data do you want? (Which columns or fields?)
- Where is it? (Which table or collection?)
- Under what conditions? (Which rows match your criteria?)
If you can answer those three questions in plain English, you are already thinking like someone who queries databases. The technical language (SQL) is just a way to write those answers down so the computer understands.
A Real-World Example …
Part (a)
A natural join keeps only rows whose common column matches, and lists the common column once.
- Common column:
LOAN_NO. - Matches:
L-170(LOAN + BORROWER RAVYA) andL-230(LOAN + BORROWER KRISH).L-171has no match in LOAN, so it is dropped -> 2 rows. …
Part (a): the natural join of LOAN and BORROWER has 2 rows and 4 columns.
Part (b): (i) 6 rows ordered by STATE descending; (ii) 4 distinct cities; (iii) four rows — KHAN, SHARMA, BHARDWAJ, SHARMA match _HA%; (iv) per-city counts KANPUR 2, ROOP NAGAR 1, DELHI 2, SONIPAT 1.
Part (a)
A natural join joins two tables on their commonly named column(s), keeps only matching rows, and shows the shared column just once. The common column is LOAN_NO.
L-170is in both tables -> one joined row.L-230is in both tables -> one joined row.L-171appears only in BORROWER, so it has no match and is excluded. …
- CBSE 2026Set 91/41 markMCQQ.A relation in MySQL database consists of 2 tuples and 3 attributes. If 2 attributes are deleted and 4 tuples are added, what will be the cardinality of the relation ? (A) 4 (B) 5 (C) 6 (D) 7
›Reveal solutionSolution
Cardinality refers to the number of tuples (rows) in a relation; deleting attributes affects only the structure, not the row count, so starting with 2 tuples and adding 4 more gives a cardinality of 6.
Understanding what happens to a relation when we modify its structure or content requires clarity on two fundamental terms: cardinality and degree. Cardinality is the number of tuples (rows) in a relation—essentially, how many records the table holds. Degree, on the other hand, is the number of attributes (columns)—the structure of the relation itself.
The question begins with a relation containing 2 tuples and 3 attributes. Picture a small table with three columns and two rows of data. Now, two operations are performed: first, 2 attributes are deleted, and second, 4 tuples are added.
Deleting attributes changes the degree of the relation. If we remove 2 out of 3 attributes, we are left with a single-column table. This operation affects the structure—the width of the table—but it does not touch the number of rows. The 2 tuples that were already present remain in the relation; they simply have fewer fields now. …
- CBSE 2025Set 91/41 markQ.State True or False : If table A has 6 rows and 3 columns, and table B has 5 rows and 2 columns, the Cartesian product of A and B will have 30 rows and 5 columns.
›Reveal solutionSolution
The statement is True — the Cartesian product of two tables combines every row of one with every row of the other, so the number of rows multiplies and the number of columns adds.
Let's think about what the Cartesian product actually does. In relational algebra, when you take the Cartesian product of two tables (say A and B), you are pairing each row of A with every row of B. The result is a new table that contains all possible combinations of rows from the two original tables.
The number of rows in the product is the product of the row counts of A and B. Here, A has 6 rows and B has 5 rows, so the result has 6 x 5 = 30 rows.
What about the columns? The Cartesian product does not merge or eliminate any columns — it simply places all columns from A side by side with all columns from B. So the total number of columns is the sum of the column counts of A and B. A has 3 columns, B has 2 columns, so the result has 3 + 2 = 5 columns.
NoteThis is exactly how the Cartesian product works in relational algebra — it is a cross join, not a natural join. No matching or merging of columns happens; every column from both tables appears in the output. …
- CBSE 2024Set 91/41 markMCQQ.The SELECT statement when combined with ____ clause, returns records without repetition. (A) DISTINCT (B) DESCRIBE (C) UNIQUE (D) NULL
›Reveal solutionSolution
SQL's
DISTINCTkeyword filters out duplicate rows from query results, ensuring each record appears only once. The answer is (A).When you query a database table, you often retrieve multiple rows that may contain identical values across all selected columns. Think of a customer orders table where the same customer ID appears dozens of times—one for each order. If you only want to see which customers have placed orders (not how many times), you need a mechanism to collapse duplicates into a single representative row.
The
SELECTstatement by itself returns every row that matches your conditions, duplicates and all. SQL provides theDISTINCTkeyword specifically to eliminate repetition: it compares the entire result set row-by-row and keeps only unique combinations.How each option relates to SQL
-
DISTINCT – This is the standard SQL keyword placed immediately after
SELECTto remove duplicate rows. For example:SELECT DISTINCT customer_id FROM orders;returns each customer ID exactly once, no matter how many orders they placed.
-
DESCRIBE – A command (or keyword in some databases) used to show the structure of a table—its column names, data types, constraints—not to filter query results. It's a metadata inspection tool, not a result-set modifier.
-
UNIQUE – In SQL,
UNIQUEis a constraint applied to columns during table creation to enforce that no two rows have the same value in that column. It's not a clause you combine withSELECTto filter results. You might see it in:CREATE TABLE users (email VARCHAR(100) UNIQUE); …
-
- CBSE 2020Set 91/D1 markQ.Which clause is used with a SELECT command in SQL to display the records in ascending order of an attribute?
›Reveal solutionSolution
The
ORDER BYclause is used with theSELECTcommand in SQL to display records in ascending order of an attribute.When we work with databases using SQL (Structured Query Language), the
SELECTcommand is our primary tool for retrieving information. Imagine a vast library of books;SELECTis like asking the librarian to fetch specific books or details about them. However, when the librarian hands you the books, they might not be in any particular order – perhaps by the order they were found, or by some internal system. For us to make sense of the data, especially when dealing with many records, we often need them arranged in a logical sequence.This need for structured presentation is where ordering comes in. Displaying records in ascending order of an attribute means arranging them from the smallest value to the largest, or alphabetically from A to Z for text. For instance, if you're looking at a list of students, you might want them sorted by their roll numbers from lowest to highest, or by their names alphabetically. This makes the data much easier to read, analyze, and understand.
To achieve this specific ordering in SQL, we use a special clause called
ORDER BY. This clause is appended to theSELECTstatement and tells the database system exactly how we want the retrieved records to be sorted.ImportantThe
ORDER BYclause is crucial for presenting query results in a meaningful and organized manner, making data analysis and reporting much more efficient.Here's how the
ORDER BYclause works:- Specifying the Attribute: You must specify one or more attributes (columns) by which you want to sort the data. For example, if you have a table of
Studentswith columns likeRollNo,Name, andMarks, you could choose to sort byRollNoorName. - Ascending Order (ASC): By default, if you just specify an attribute with
ORDER BY, the records will be sorted in ascending order. However, it's good practice to explicitly use theASCkeyword to make your intention clear.ASCstands for Ascending. This means numbers will go from smallest to largest, and text will go from A to Z. …
- Specifying the Attribute: You must specify one or more attributes (columns) by which you want to sort the data. For example, if you have a table of
🎓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.