Chapter 3 — Introduction to Database Management System: Exercise Solutions Guide
How to Use This Page
1. Attempt every exercise question on your own first — use your Samacheer Kalvi textbook and class notes. 2. Compare your answers with the solutions below only after you have written your own. 3. Read the explanations for MCQs and True/False items — understanding why an answer is correct is more important than the answer itself. 4. Practise the short and detailed answers by writing them in your own words; do not memorise verbatim. 5. Use the Exam Checklist at the end for a quick pre-exam revision round.
Key Concepts (Quick Recap)
- A database is an organised collection of related data stored in a structured format.
- A DBMS (Database Management System) is software that allows users to create, store, retrieve, update, and manage data efficiently.
- A data model defines how data is structured and related; types include hierarchical, network, relational, and object-oriented.
- The hierarchical model organises data in a tree structure (parent-child relationship) — e.g., IBM's IMS.
- The network model allows many-to-many relationships — data is organised as a graph with nodes and edges.
- The relational model (most widely used) stores data in tables (relations) with rows (tuples) and columns (attributes) — e.g., MySQL, Oracle.
- A table is a collection of related data organised in rows and columns; each row is a record (tuple) and each column is a field (attribute).
- A primary key uniquely identifies each record in a table; it cannot contain NULL or duplicate values.
- A foreign key is a column in one table that references the primary key of another table, creating a relationship.
- SQL (Structured Query Language) is the standard language for interacting with relational databases — commands include SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP.
- Normalization is the process of reducing data redundancy and dependency by dividing tables into smaller, well-structured ones (1NF, 2NF, 3NF).
I. Choose the Best Answer (MCQs)
1. A Database Management System is: (a) Hardware that stores data (b) Software that manages data in a structured way (c) A programming language (d) An operating system
Answer(b) Software that manages data in a structured way A DBMS is application software that provides tools to create, store, retrieve, update, and manage databases. Examples include MySQL, Oracle, and Microsoft SQL Server.
2. In a relational database, data is stored in: (a) Trees (b) Graphs (c) Tables (d) Linked lists
Answer(c) Tables The relational model organises data into tables (relations). Each table has rows (tuples/records) and columns (attributes/fields). This tabular structure is the foundation of RDBMS.
3. Which of the following is a primary key characteristic? (a) It can contain NULL values (b) It can have duplicate values (c) It uniquely identifies each record (d) It is always a numeric field
Answer(c) It uniquely identifies each record A primary key must uniquely identify each row in a table. It cannot contain NULL values or duplicate values. It can be any data type, not just numeric.
4. The SQL command used to retrieve data from a database is: (a) INSERT (b) UPDATE (c) SELECT (d) DELETE
Answer(c) SELECT SELECT is the SQL command for querying and retrieving data from one or more tables. INSERT adds new records, UPDATE modifies existing records, and DELETE removes records.
5. A foreign key is used to: (a) Encrypt data (b) Create a relationship between two tables (c) Sort data in descending order (d) Delete duplicate records
Answer(b) Create a relationship between two tables A foreign key in one table references the primary key of another table, establishing a link (relationship) between the two tables. This is fundamental to relational database design.
6. Which data model uses a tree structure to represent data? (a) Network model (b) Relational model (c) Hierarchical model (d) Object-oriented model
Answer(c) Hierarchical model The hierarchical model organises data in a tree-like structure with parent-child relationships, where each parent can have multiple children, but each child has only one parent. Example: IBM's IMS.
7. Normalization is done to: (a) Increase data redundancy (b) Reduce data redundancy and dependency (c) Speed up hardware performance (d) Create more tables for no reason
Answer(b) Reduce data redundancy and dependency Normalization divides large tables into smaller, related tables to eliminate data redundancy (duplicate data) and dependency anomalies. This improves data integrity and reduces storage waste.
8. Which SQL command is used to create a new table? (a) INSERT TABLE (b) MAKE TABLE (c) CREATE TABLE (d) NEW TABLE
Answer(c) CREATE TABLE CREATE TABLE is the standard DDL (Data Definition Language) command to create a new table with specified columns and data types. Example: CREATE TABLE Students (id INT PRIMARY KEY, name VARCHAR(50));
9. In a table, a row is called a: (a) Attribute (b) Tuple (c) Schema (d) Domain
Answer(b) Tuple In relational database terminology, a row (horizontal record) is called a tuple. A column (vertical) is called an attribute. Schema is the overall structure, and domain is the set of valid values for an attribute.
10. Which normal form eliminates partial dependency? (a) 1NF (b) 2NF (c) 3NF (d) BCNF
Answer(b) 2NF The Second Normal Form (2NF) eliminates partial dependencies — where a non-key attribute depends on only part of a composite primary key. 1NF eliminates repeating groups, 3NF eliminates transitive dependencies, and BCNF is a stricter version of 3NF.
II. Fill in the Blanks
1. A DBMS is software that manages data in a structured and organised way. 2. In a relational database, data is stored in tables (relations). 3. A primary key uniquely identifies each record in a table. 4. A foreign key references the primary key of another table to create a relationship. 5. The SQL command to retrieve data is SELECT. 6. The hierarchical model organises data in a tree structure. 7. A column in a database table is called an attribute (field). 8. Normalization is the process of reducing data redundancy and dependency. 9. The SQL command to add new records is INSERT. 10. The full form of SQL is Structured Query Language.
III. True or False
1. A DBMS can manage only one table at a time.
AnswerFalse — A DBMS can manage multiple tables and the relationships between them simultaneously.
2. A primary key can contain NULL values.
AnswerFalse — A primary key must be unique and cannot contain NULL values. This ensures every record can be uniquely identified.
3. The network model supports many-to-many relationships.
AnswerTrue — Unlike the hierarchical model (which supports only one-to-many), the network model allows a child record to have multiple parent records, enabling many-to-many relationships.
4. SQL is a procedural programming language.
AnswerFalse — SQL is a non-procedural (declarative) language. You specify what data you want, not how to retrieve it.
5. A foreign key always references a primary key in another table.
AnswerTrue — A foreign key creates a link between two tables by referencing the primary key of the referenced table.
6. 1NF requires that each column contains atomic (indivisible) values.
AnswerTrue — First Normal Form requires that every column contains only atomic (single, indivisible) values — no repeating groups or arrays within a single cell.
7. The DELETE command removes an entire table from the database.
AnswerFalse — DELETE removes rows (records) from a table. The DROP TABLE command removes the entire table structure.
8. In a relational model, each table must have a primary key.
AnswerTrue — While technically a table can exist without a primary key, best practice in relational database design requires every table to have a primary key for unique identification.
9. Normalization increases data redundancy.
AnswerFalse — Normalization reduces data redundancy by dividing tables into smaller, well-structured ones.
10. The UPDATE command is used to modify existing records in a table.
AnswerTrue — UPDATE modifies existing data in one or more records. Example: UPDATE Students SET marks = 85 WHERE id = 101;
IV. Match the Following
Set A
| Column A | Column B |
|---|
| 1. Hierarchical model | (c) Tree structure |
| 2. Network model | (e) Graph structure with many-to-many |
| 3. Relational model | (a) Tables with rows and columns |
| 4. Primary key | (d) Uniquely identifies each record |
| 5. Foreign key | (b) References primary key of another table |
Set B
| Column A | Column B |
|---|
| 1. SELECT | (d) Retrieve data |
| 2. INSERT | (a) Add new records |
| 3. UPDATE | (e) Modify existing records |
| 4. DELETE | (b) Remove records |
| 5. CREATE TABLE | (c) Define a new table structure |
V. Short Answer Questions
1. Define database and DBMS. Give two examples of DBMS software.
Answer
A database is an organised collection of related data that can be easily accessed, managed, and updated. Data in a database is structured in tables, records, and fields.
A DBMS (Database Management System) is software that provides tools to create, store, retrieve, update, and manage data in a database. It ensures data integrity, security, and concurrency.
Examples of DBMS software: 1. MySQL — open-source, widely used for web applications 2. Oracle — enterprise-grade, used by large organisations 3. Microsoft SQL Server — used in Windows-based enterprise environments 4. SQLite — lightweight, embedded in mobile and desktop applications
2. What is a primary key? How does it differ from a foreign key?
Answer
| Feature | Primary Key | Foreign Key |
|---|
| Purpose | Uniquely identifies each record | References a primary key in another table |
| Uniqueness | Must be unique | Can have duplicate values |
| NULL | Cannot be NULL | Can be NULL (in some cases) |
| Table | Defined in the parent table | Defined in the child table |
| Count per table | Only one primary key per table | Can have multiple foreign keys per table |
| Example | Student_ID in Students table | Student_ID in Marks table referencing Students |
3. Explain the hierarchical data model with an example.
Answer
The hierarchical model organises data in a tree-like structure where:
- Each node represents a record type
- Parent nodes can have multiple child nodes
- Each child node has exactly one parent node
- Relationships are one-to-many (1:N)
Example: A college database:
College
/ \
Department Department
/ \ / \
Teacher Teacher Teacher Course
In this structure:
- College is the root (parent)
- Departments are children of College
- Teachers and Courses are children of their respective Departments
- A Teacher belongs to only one Department (one parent)
Advantages: Simple structure, fast data access through predefined paths Disadvantages: Cannot represent many-to-many relationships easily; adding new relationships requires restructuring the entire hierarchy
4. What is SQL? Name its sub-languages with one command each.
Answer
SQL (Structured Query Language) is a standard language used to interact with relational databases. It allows users to create, read, update, and delete data.
SQL sub-languages:
| Sub-language | Purpose | Example Command |
|---|
| DDL (Data Definition Language) | Define structure | CREATE TABLE |
| DML (Data Manipulation Language) | Manipulate data | INSERT, UPDATE, DELETE |
| DQL (Data Query Language) | Query data | SELECT |
| DCL (Data Control Language) | Control access | GRANT, REVOKE |
| TCL (Transaction Control Language) | Manage transactions | COMMIT, ROLLBACK |
5. What is normalization? Explain 1NF, 2NF, and 3NF briefly.
Answer
Normalization is the process of organising data in a database to reduce redundancy and eliminate insert, update, and delete anomalies.
1NF (First Normal Form):
- Every column contains atomic (indivisible) values
- No repeating groups or arrays
- Each row is unique (has a primary key)
2NF (Second Normal Form):
- Must be in 1NF
- No partial dependency — every non-key attribute must depend on the entire primary key (not just part of it)
- Relevant only for tables with composite primary keys
3NF (Third Normal Form):
- Must be in 2NF
- No transitive dependency — non-key attributes must not depend on other non-key attributes
- Every non-key attribute depends only on the primary key
6. Differentiate between DELETE and DROP commands.
Answer
| Feature | DELETE | DROP |
|---|
| Purpose | Removes specific rows from a table | Removes entire table (structure + data) |
| Scope | Row-level operation | Table-level operation |
| Rollback | Can be rolled back (with transactions) | Cannot be rolled back |
| WHERE clause | Supported | Not applicable |
| Structure | Table structure remains | Table structure is removed |
| Speed | Slower (logs each row) | Faster (removes entire object) |
| Example | DELETE FROM Students WHERE id = 5; | DROP TABLE Students; |
VI. Detailed Answer Questions
1. Explain the different data models in DBMS with examples and diagrams.
Answer
A data model defines how data is structured, stored, and related in a database. The main data models are:
1. Hierarchical Model:
Answer
- Data is organised in a tree structure (parent-child)
- Each parent can have multiple children; each child has one parent
- Supports one-to-many relationships
- Navigation: top-down through predefined paths
- Example: IBM IMS (Information Management System)
College
/ \
Science Arts
/ \ / \
Physics Math History English
Advantages: Simple, fast for known queries Disadvantages: Rigid structure, hard to represent many-to-many relationships
2. Network Model:
Answer
- Data is organised as a graph (nodes and edges)
- A child can have multiple parents (many-to-many relationships)
- More flexible than hierarchical model
- Uses sets to represent relationships
- Example: IDMS (Integrated Database Management System)
Student ────── Course
\ / |
\ / |
Teacher───/
Advantages: Handles many-to-many relationships, efficient data access Disadvantages: Complex structure, difficult to design and maintain
3. Relational Model:
Answer
- Data is stored in tables (relations)
- Each table has rows (tuples) and columns (attributes)
- Relationships are established through primary and foreign keys
- Most widely used model
- Example: MySQL, Oracle, PostgreSQL
Students Table:
| Roll_No | Name | Class |
|---|
| 101 | Arun | XII |
| 102 | Bharathi | XII |
Advantages: Simple, flexible, powerful query language (SQL), data integrity Disadvantages: Can be slower for complex hierarchical queries
4. Object-Oriented Model:
Answer
- Data is stored as objects with attributes and methods
- Supports complex data types (inheritance, encapsulation, polymorphism)
- Example: ObjectDB, db4o
2. Explain the relational database model in detail with an example.
Answer
The relational model was introduced by E.F. Codd in 1970. It organises data into tables (called relations) with rows and columns. Relationships between tables are established through keys.
Key Terminology:
- Relation (Table) — a named structure with rows and columns
- Tuple (Row/Record) — a single data entry in a table
- Attribute (Column/Field) — a named column with a specific data type
- Domain — the set of all valid values for an attribute
- Degree — the number of columns in a table
- Cardinality — the number of rows in a table
- Schema — the structure definition of a table (column names and data types)
Example — School Database:
Students Table:
| Roll_No (PK) | Name | Class | Section |
|---|
| 101 | Arun | XII | A |
| 102 | Bharathi | XII | B |
| 103 | Chandru | XI | A |
Marks Table:
| Mark_ID (PK) | Roll_No (FK) | Subject | Marks |
|---|
| 1 | 101 | Computer App | 85 |
| 2 | 101 | Maths | 92 |
| 3 | 102 | Computer App | 78 |
Relationship: The Roll_No in Marks table is a foreign key referencing the Roll_No in Students table. This links each mark to the corresponding student.
Properties of the Relational Model: 1. Each column has a unique name (attribute name) 2. Each column contains values of the same data type (domain) 3. Each row is unique (enforced by primary key) 4. The order of rows and columns does not matter 5. Each cell contains only one atomic value (1NF)
Advantages:
- Simple tabular structure is easy to understand
- Powerful query language (SQL)
- Data integrity through constraints (primary key, foreign key, NOT NULL, UNIQUE)
- Data independence — changes to storage don't affect queries
- Supports multiple users with concurrency control
3. Explain the different types of keys in DBMS with examples.
Answer
Keys are crucial in relational databases for identifying records and establishing relationships.
1. Primary Key:
Answer
- Uniquely identifies each record in a table
- Cannot contain NULL values
- Cannot have duplicate values
- Only one primary key per table
Example: In a Students table, Roll_No can be the primary key because each student has a unique roll number.
CREATE TABLE Students (
Roll_No INT PRIMARY KEY,
Name VARCHAR(50),
Class VARCHAR(10)
);
2. Foreign Key:
Answer
- A column in one table that references the primary key of another table
- Creates a relationship between two tables
- Can contain duplicate values
- Can contain NULL values (if allowed)
Example: Roll_No in the Marks table is a foreign key referencing Roll_No in the Students table.
CREATE TABLE Marks (
Mark_ID INT PRIMARY KEY,
Roll_No INT,
Subject VARCHAR(30),
Marks INT,
FOREIGN KEY (Roll_No) REFERENCES Students(Roll_No)
);
3. Candidate Key:
Answer
- A column (or set of columns) that can uniquely identify each record
- A table can have multiple candidate keys
- One candidate key is chosen as the primary key
Example: In a Students table, both Roll_No and Admission_No can uniquely identify students. Both are candidate keys; one is chosen as the primary key.
4. Alternate Key:
Answer
- A candidate key that is NOT chosen as the primary key
- Acts as a backup unique identifier
Example: If Roll_No is chosen as the primary key, then Admission_No becomes the alternate key.
5. Composite Key:
Answer
- A primary key made up of two or more columns
- Used when no single column can uniquely identify records
Example: In a Marks table, the combination of Roll_No and Subject can form a composite primary key.
6. Super Key:
Answer
- A set of one or more columns that can uniquely identify a record
- May contain extra columns beyond what is necessary
Example: {Roll_No, Name} is a super key because Roll_No alone is sufficient, but adding Name still maintains uniqueness.
| Key Type | Uniqueness | NULL Allowed | Count per Table |
|---|
| Primary Key | Yes | No | 1 |
| Foreign Key | No | Yes | Multiple |
| Candidate Key | Yes | No | Multiple |
| Alternate Key | Yes | No | Multiple |
| Composite Key | Yes (combined) | No | 1 (as PK) |
| Super Key | Yes | Depends | Multiple |
4. Explain the different normal forms (1NF, 2NF, 3NF) with examples.
Answer
Normalization is the step-by-step process of organising data to reduce redundancy and eliminate anomalies.
First Normal Form (1NF): A table is in 1NF if:
- Every column contains atomic (indivisible) values
- There are no repeating groups
- Each row is unique (has a primary key)
Unnormalised table (NOT in 1NF):
| Student_ID | Name | Subjects |
|---|
| 101 | Arun | Maths, Science, English |
| 102 | Bharathi | Maths, History |
The "Subjects" column contains multiple values — this violates 1NF.
After 1NF:
| Student_ID | Name | Subject |
|---|
| 101 | Arun | Maths |
| 101 | Arun | Science |
| 101 | Arun | English |
| 102 | Bharathi | Maths |
| 102 | Bharathi | History |
Now every column has atomic values.
Second Normal Form (2NF): A table is in 2NF if:
- It is in 1NF
- There is no partial dependency — every non-key attribute depends on the entire primary key
1NF table with partial dependency (NOT in 2NF):
| Student_ID | Subject | Student_Name | Teacher |
|---|
| 101 | Maths | Arun | Mr. Rajan |
| 101 | Science | Arun | Ms. Kala |
Primary key: (Student_ID, Subject) — composite key
Partial dependency: Student_Name depends only on Student_ID, not on the full composite key. This is a partial dependency.
After 2NF (split into two tables):
Students:
| Student_ID | Student_Name |
|---|
| 101 | Arun |
| 102 | Bharathi |
Subjects:
| Student_ID | Subject | Teacher |
|---|
| 101 | Maths | Mr. Rajan |
| 101 | Science | Ms. Kala |
Now every non-key attribute depends on the entire primary key.
Third Normal Form (3NF): A table is in 3NF if:
- It is in 2NF
- There is no transitive dependency — non-key attributes do not depend on other non-key attributes
2NF table with transitive dependency (NOT in 3NF):
| Student_ID | Student_Name | Zip_Code | City |
|---|
| 101 | Arun | 600001 | Chennai |
| 102 | Bharathi | 600002 | Chennai |
Transitive dependency: City depends on Zip_Code, and Zip_Code depends on Student_ID. So City transitively depends on Student_ID through Zip_Code.
After 3NF (split into two tables):
Students:
| Student_ID | Student_Name | Zip_Code |
|---|
| 101 | Arun | 600001 |
| 102 | Bharathi | 600002 |
Cities:
| Zip_Code | City |
|---|
| 600001 | Chennai |
| 600002 | Chennai |
Now there are no transitive dependencies.
Summary:
| Normal Form | Rule | Eliminates |
|---|
| 1NF | Atomic values, no repeating groups | Multi-valued attributes |
| 2NF | No partial dependency | Partial dependency on composite key |
| 3NF | No transitive dependency | Non-key depending on non-key |
5. Explain SQL commands for creating tables, inserting data, and querying data with examples.
1. CREATE TABLE — Defining Table Structure
CREATE TABLE Students (
Roll_No INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Class VARCHAR(10),
Marks INT
);
Answer
This creates a table named "Students" with four columns:
Roll_No — integer type, set as primary keyName — variable character (up to 50 characters), cannot be NULLClass — variable character (up to 10 characters)Marks — integer type
2. INSERT INTO — Adding Data
-- Insert a single record
INSERT INTO Students (Roll_No, Name, Class, Marks)
VALUES (101, 'Arun', 'XII', 85);
-- Insert multiple records
INSERT INTO Students (Roll_No, Name, Class, Marks)
VALUES
(102, 'Bharathi', 'XII', 92),
(103, 'Chandru', 'XI', 78),
(104, 'Deepa', 'XII', 88);
3. SELECT — Querying Data
-- Retrieve all records
SELECT * FROM Students;
-- Retrieve specific columns
SELECT Name, Marks FROM Students;
-- Retrieve with condition
SELECT * FROM Students WHERE Marks > 80;
-- Retrieve with multiple conditions
SELECT * FROM Students WHERE Class = 'XII' AND Marks > 85;
-- Retrieve with pattern matching
SELECT * FROM Students WHERE Name LIKE 'A%';
-- Sort results
SELECT * FROM Students ORDER BY Marks DESC;
-- Retrieve distinct values
SELECT DISTINCT Class FROM Students;
-- Aggregate functions
SELECT COUNT(*) FROM Students;
SELECT AVG(Marks) FROM Students;
SELECT MAX(Marks) FROM Students;
SELECT MIN(Marks) FROM Students;
SELECT SUM(Marks) FROM Students;
4. UPDATE — Modifying Existing Data
-- Update specific record
UPDATE Students SET Marks = 90 WHERE Roll_No = 101;
-- Update multiple records
UPDATE Students SET Class = 'XII' WHERE Class = '12th';
5. DELETE — Removing Data
-- Delete specific record
DELETE FROM Students WHERE Roll_No = 104;
-- Delete all records (table structure remains)
DELETE FROM Students;
6. ALTER TABLE — Modifying Table Structure
-- Add a new column
ALTER TABLE Students ADD Email VARCHAR(100);
-- Drop a column
ALTER TABLE Students DROP COLUMN Email;
7. DROP TABLE — Removing Entire Table
DROP TABLE Students;
Answer
This removes the entire table structure along with all data — it cannot be rolled back.
Common Mistakes
1. Confusing primary key with foreign key — Primary key uniquely identifies records in its own table; foreign key references another table's primary key to create relationships. 2. Thinking DELETE removes the table structure — DELETE removes rows (data) but the table structure remains. DROP TABLE removes both structure and data. 3. Confusing hierarchical and network models — Hierarchical uses a tree (one parent per child); network uses a graph (multiple parents allowed). 4. Forgetting that 2NF only applies to composite keys — If the primary key is a single column, 1NF automatically satisfies 2NF (no partial dependency possible). 5. Writing SQL without WHERE in UPDATE/DELETE — UPDATE Students SET Marks = 100 updates ALL rows. Always use WHERE to specify which records to modify. 6. Confusing degree and cardinality — Degree is the number of columns; cardinality is the number of rows. 7. Assuming foreign keys must be unique — Foreign keys can have duplicate values. Only primary keys must be unique.
Exam Checklist
- [ ] Can define database, DBMS, and RDBMS with examples
- [ ] Can explain hierarchical, network, and relational data models with examples
- [ ] Know the difference between primary key, foreign key, candidate key, and composite key
- [ ] Can write SQL commands: CREATE TABLE, INSERT, SELECT, UPDATE, DELETE
- [ ] Understand normalization: 1NF, 2NF, 3NF with examples
- [ ] Can identify and correct partial and transitive dependencies
- [ ] Know the difference between DDL, DML, DQL, DCL, and TCL
- [ ] Can explain relational model terminology: tuple, attribute, degree, cardinality, domain, schema
- [ ] Understand the advantages and disadvantages of each data model
- [ ] Can differentiate between DELETE and DROP commands