NCERT Solutions Class 12 Computer Science Chapter 8 Database Concepts
Complete Question Bank - 20 Questions with Detailed Solutions
1
Question
What is relation? Define the relational data model.
Answer
A relation is a table having atomic values, unique rows, and unordered rows and columns. Each relation represents an entity and contains information about that entity.
The relational data model represents data and relationships among data by a collection of tables known as relations, each of which has a number of columns with unique names. Key features include:
- Data is stored in tables (relations)
- Each table has rows (tuples) and columns (attributes)
- Each column has a unique name
- All values in a column are of the same data type
- Each row is unique
- Order of rows and columns is immaterial
2
Question
What are all the domain names possible in gender?
Answer
The possible domain names for gender are:
- Male
- Female
In database terminology, a domain defines the set of possible values that an attribute can contain. For the gender attribute, the domain is restricted to these two values to maintain data consistency and integrity.
3
Question
Give a suitable example of a table with sample data and illustrate Primary and Candidate Keys in it.
Answer
Candidate Keys: A table may have more than one attribute or group of attributes that identifies a row/tuple uniquely. All such attributes are known as Candidate Keys.
Primary Key: Out of the Candidate keys, one is selected as Primary Key.
Example: STUDENT Table
| Student_ID | Roll_No | Name | |
|---|---|---|---|
| 101 | CS001 | John Smith | john@email.com |
| 102 | CS002 | Alice Brown | alice@email.com |
| 103 | CS003 | Bob Wilson | bob@email.com |
Candidate Keys: Student_ID, Roll_No, Email (each uniquely identifies a student)
Primary Key: Student_ID (selected from candidate keys)
4
Question
Differentiate between cardinality and degree of a table with the help of an example.
Answer
Cardinality: The number of rows (tuples) in a table.
Degree: The number of columns (attributes) in a table.
Example: ACCOUNT Table
| Account_No | Balance |
|---|---|
| 1001 | 25000 |
| 1002 | 30000 |
| 1003 | 15000 |
Cardinality of ACCOUNT table: 3 (number of rows)
Degree of ACCOUNT table: 2 (number of columns)
Table diagram would be displayed here from original document
5
Question
Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) candidate keys and (ii) primary key.
Table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-3.png
Answer
Based on the table analysis:
- Candidate keys: Id, Product
- Primary key: Id
Explanation: Both Id and Product can uniquely identify each row in the table, making them candidate keys. Id is chosen as the primary key as it's typically more stable and efficient for database operations.
6
Question
Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) candidate keys and (ii) primary key:
Table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-4.png
Answer
Based on the table analysis:
- Candidate keys: Code, Item
- Primary key: Code
Explanation: Both Code and Item attributes can uniquely identify each record in the table, making them candidate keys. Code is selected as the primary key as it's typically more efficient for indexing and referencing.
7
Question
Define degree and cardinality. Based upon given table write degree and cardinality.
PATIENTS table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-5.png
Answer
Definitions:
- Degree: The number of attributes or columns present in a table.
- Cardinality: The number of tuples or rows present in a table.
For the PATIENTS table:
Degree: 4 (number of columns)
Cardinality: 5 (number of rows)
8
Question
Differentiate between the Primary key and Alternate key of a table with the help of an example.
Answer
Primary Key: A primary key is a value that can be used to identify a unique row in a table. It cannot be null and must be unique.
Alternate Key: An alternate key is any candidate key which is not selected to be the primary key.
Example: CUSTOMER Table
| Aadhaar_Number | Bank_Account_Number | Name | Phone |
|---|---|---|---|
| 1234-5678-9012 | ACC001 | John Doe | 9876543210 |
| 2345-6789-0123 | ACC002 | Jane Smith | 8765432109 |
Both Aadhaar_Number and Bank_Account_Number are candidate keys.
Primary Key: Aadhaar_Number
Alternate Key: Bank_Account_Number
Example table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-6.png
9
Question
Explain the concept of candidate keys with the help of an appropriate example.
Answer
Candidate Key: A candidate key is a column or set of columns that can help in identifying records uniquely in a table. A table may have multiple candidate keys.
Example: STUDENT Table
| AdminNo | RollNo | Name | Class |
|---|---|---|---|
| A001 | CS001 | Alex Johnson | 12-A |
| A002 | CS002 | Sarah Wilson | 12-B |
| A003 | CS003 | Mike Brown | 12-A |
Here, both AdminNo and RollNo uniquely identify each student record.
Hence, they are candidate keys.
STUDENT table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-7.png
10
Question
A table customer has 10 columns but no row. Later, 10 new rows are inserted and 3 rows are deleted in the table. What is the degree and cardinality of the table customer?
Answer
Step-by-step calculation:
- Initial state: 10 columns, 0 rows
- After inserting 10 rows: 10 columns, 10 rows
- After deleting 3 rows: 10 columns, 7 rows
Degree: 10 (number of columns remains constant)
Cardinality: 7 (10 - 3 = 7 rows remaining)
Note: Degree represents the structure of the table (columns) and doesn't change unless columns are added or removed. Cardinality represents the data in the table (rows) and changes when rows are inserted or deleted.
11
Question
A table student has 3 columns and 10 rows and another table student2 has the same number of columns and 15 rows. 5 rows are common in both the tables. If we take union, what is the degree and cardinality of the resultant table?
Answer
Given:
- Table student: 3 columns, 10 rows
- Table student2: 3 columns, 15 rows
- Common rows: 5
Union Operation: The union operation combines all unique rows from both tables, eliminating duplicates.
Degree: 3 (same as both tables)
Cardinality: 10 + 15 - 5 = 20
(Total rows from both tables minus common rows)
Note: The degree remains the same as both tables have the same structure. The cardinality is calculated by adding all rows and subtracting the duplicates.
12
Question
A table student has 4 columns and 10 rows and table student2 has 5 columns and 5 rows. If we take Cartesian product of these two tables, what is the degree and cardinality of the resultant table?
Answer
Given:
- Table student: 4 columns, 10 rows
- Table student2: 5 columns, 5 rows
Cartesian Product: The Cartesian product combines every row of the first table with every row of the second table.
Degree: 4 + 5 = 9 columns
(Sum of columns from both tables)
Cardinality: 10 × 5 = 50 rows
(Product of rows from both tables)
Formula:
Degree of result = Degree of Table1 + Degree of Table2
Cardinality of result = Cardinality of Table1 × Cardinality of Table2
13
Question
Observe the following table and answer the parts (i) and (ii):
Table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-8.png
- In the above table, can we have Qty as primary key? [Answer as yes/no]. Justify your answer.
- What is the cardinality and degree of the above table?
Answer
1. Can Qty be used as primary key?
No, Qty cannot be used as primary key.
Justification: Primary key values must be unique for each record. If there are duplicate values in the Qty column, it violates the uniqueness constraint required for a primary key.
2. Cardinality and Degree:
Degree: 4 (number of columns)
Cardinality: 5 (number of rows)
Key Point: A primary key must have unique, non-null values. Any column with duplicate values cannot serve as a primary key.
14
Question
What do you understand by Union & Cartesian product in the relational algebra?
Answer
Union Operation (∪):
The Union of two relations R and S is a relation that includes all the tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated.
Conditions for Union:
- Both relations must have the same number of attributes
- Corresponding attributes must have the same domain
- Duplicate rows are removed from the result
Cartesian Product (×):
The Cartesian Product is an operator which works on two sets. It combines each tuple of one relation with all the tuples of the other relation.
Result characteristics:
- Degree = Degree of R + Degree of S
- Cardinality = Cardinality of R × Cardinality of S
- No conditions required on the relations
Cartesian Product example from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-9.png
15
Question
Explain the concept of union between two tables, with the help of appropriate example.
Answer
The union operation denoted by ∪ combines two or more relations. The resultant of union operation contains tuples that are in either of the tables or in both tables, with duplicates eliminated.
Example: Union of Student Tables
Table A (Computer Science Students):
| ID | Name |
|---|---|
| 1 | Alice |
| 2 | Bob |
| 3 | Charlie |
Table B (Mathematics Students):
| ID | Name |
|---|---|
| 2 | Bob |
| 4 | Diana |
| 5 | Eve |
Result: A ∪ B (All Students):
| ID | Name |
|---|---|
| 1 | Alice |
| 2 | Bob |
| 3 | Charlie |
| 4 | Diana |
| 5 | Eve |
Note: Bob (ID=2) appears only once in the result as duplicates are eliminated.
Union operation example from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-10.png
16
Question
In the following 2 tables, find the union value of Student1 and Student2.
Student1 and Student2 tables from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-11.png
Answer
To find the union of Student1 and Student2 tables, we need to:
- Combine all rows from both tables
- Remove any duplicate rows
- Ensure both tables have the same structure (same number and type of columns)
Steps for Union Operation:
- Verify that both tables have compatible schemas
- Combine all unique rows from Student1
- Add all unique rows from Student2 that are not already present
- Result contains all distinct rows from both tables
Note: The specific union result would depend on the actual data shown in the referenced image. The union will contain all unique combinations of values from both tables.
17
Question
Observe the table Club given below:
Club table from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-12.png
- What is the cardinality and degree of the above given table?
- If a new column contact no has been added and three more members have joined the club then how these changes will affect the degree and cardinality of the above given table.
Answer
1. Current table characteristics:
Cardinality: 4 (number of members/rows)
Degree: 5 (number of attributes/columns)
2. After changes:
Adding new column (contact no):
- Degree increases from 5 to 6
- Cardinality remains 4
Adding three more members:
- Degree remains 6
- Cardinality increases from 4 to 7
Final Result:
Cardinality: 7 (4 original + 3 new members)
Degree: 6 (5 original + 1 new column)
18
Question
In which situation can we apply union operation of two tables?
Answer
Union operation between two tables can be applied when the following conditions are met:
Conditions for Union Operation:
- Same number of columns: Both tables must have exactly the same number of attributes/columns.
- Similar data types: Corresponding columns in both tables must have compatible data types.
- Same order of columns: The columns must be in the same order in both tables, or the order must be specified to match.
Examples of Valid Union Scenarios:
- Combining student records from different classes with same structure
- Merging employee data from different departments
- Combining product catalogs from different suppliers
- Uniting customer records from multiple branches
Invalid Union Scenarios:
- Tables with different number of columns
- Tables with incompatible data types in corresponding columns
- Tables representing completely different entities without common structure
Note: The union operation automatically eliminates duplicate rows from the result, ensuring each unique combination of values appears only once.
Short Answer Type Questions II
19
Question
Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in LIST. Also, find the Degree and Cardinality of the LIST.
STUDENTS and EVENTS tables from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-13.png
Answer
RDBMS Operation: Cartesian Product (×)
Characteristics of the LIST:
- Degree: 4 (sum of columns from both tables)
- Cardinality: 6 (product of rows from both tables)
Explanation: The Cartesian product operation combines every row from the STUDENTS table with every row from the EVENTS table. This creates a new relation where:
- Each student is paired with each event
- The result contains all possible combinations
- No filtering or matching conditions are applied
20
Question
Observe the following PARTICIPANTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in RESULT. Also, find the Degree and Cardinality of the RESULT.
PARTICIPANTS and EVENTS tables from NCERT-Solutions-Class-12-Computer-Science-Database-Concepts-14.png
Answer
RDBMS Operation: Cartesian Product (×)
Characteristics of the RESULT:
- Degree: 4 (number of columns in the result)
- Cardinality: 6 (number of rows in the result)
Process: The Cartesian product operation creates a comprehensive combination where:
- Every participant is matched with every event
- All attributes from both tables are included
- The operation generates all possible pairings
Formula Applied:
Result Degree = Degree of PARTICIPANTS + Degree of EVENTS
Result Cardinality = Cardinality of PARTICIPANTS × Cardinality of EVENTS
Chapter Summary - Key Concepts
Database Fundamentals
- • Relation: Table with atomic values and unique rows
- • Relational Model: Data stored in interconnected tables
- • Domain: Set of possible values for an attribute
Keys in Database
- • Candidate Key: Attributes that uniquely identify rows
- • Primary Key: Selected candidate key for identification
- • Alternate Key: Non-selected candidate keys
Table Properties
- • Degree: Number of columns/attributes
- • Cardinality: Number of rows/tuples
- • Both are fundamental table characteristics
Relational Operations
- • Union: Combines tables with same structure
- • Cartesian Product: All possible row combinations
- • Both operations have specific degree/cardinality rules

