Database Management System (DBMS)
Class 10 Computer Science
Comprehensive study guide, relational keys, Structured Query Language (SQL), and fully solved textbook exercises for SEE preparation.
Welcome to the ultimate guide on Database Management System (DBMS). This is Unit 2 for Class 10 Computer Science students preparing for their SEE board exams.
In this guide, you will explore the depths of database architectures, differentiate between raw data and structured information, write efficient SQL statements, master keys, and obtain a fully resolved set of CDC textbook exercises.
1. Comprehensive Theory of Database Management System (DBMS)
2.1 Introduction to Databases
In today’s digital world, databases play an essential role in almost every computer system. Whether we are booking a flight ticket, logging into a social media account, watching videos on a streaming app, or sending instant messages, databases are quietly working in the background to manage the flow of data.
A database is a systematic, organized collection of data stored and managed electronically so that it can be accessed, retrieved, updated, and protected easily and efficiently.
In our daily lives, we encounter countless situations where we need to store and retrieve information:
A database works like a “digital cupboard”—it keeps everything in perfect order, secure, and safe from getting lost, corrupted, or mixed up.
Let’s Think!
Why might a school want to store student records in a computerized database rather than a traditional paper file or a basic, flat Excel sheet?
How Databases Are Used Around Us
| Area | How Databases Are Used |
|---|---|
| Social Media | Stores user profiles, posts, media uploads, likes, shares, comments, and follower lists. |
| Online Shopping | Keeps real-time product catalogs, pricing structures, stock levels, orders, and customer reviews. |
| Banking | Safely manages accounts, secure transactions, account balances, and security logs. |
| Healthcare | Stores patient records, lab test results, prescriptions, and medical histories. |
| Cloud Databases | Companies like Google and Amazon run online database services that can be accessed from anywhere. |
Note on Cloud Databases: Cloud databases have surged in popularity because they operate over the Internet. They eliminate the need for physical, on-site server hardware, automatically scale with business growth, and offer high availability.
2.2 Data, Database, and Database Management System (DBMS)
A. Data vs. Information
To understand database design, we must first distinguish between raw inputs and processed outputs:
$$\text{Data} \xrightarrow{\text{Processing / Structuring}} \text{Information}$$
Concept Example: If the raw numbers “80, 85, 90” are marks, they are data (we do not know who scored them, in what subject, or when). Once processed, the statement: “The student scored an average of 85 marks in the final term” is information.
Technical Comparison: Data vs. Information
| Aspect | Data | Information |
|---|---|---|
| Definition | Raw, unprocessed, and unorganized facts or figures. | Processed, structured, and organized data with a clear meaning. |
| Form | Isolated numbers, text, symbols, images, etc. | Analyzed, formatted data presented in context. |
| Meaning | No clear meaning or baseline value on its own. | Meaningful, actionable, and useful for understanding. |
| Example | “2082, 95, Binay” | “Binay scored 95 marks in 2082 BS, and is one of the top performers.” |
B. Evolution of Storage: Traditional File System vs. Modern DBMS
Before computerization, data was maintained using manual or flat file configurations.
Structural Comparison Table
| Feature | Traditional File System | Database Management System (DBMS) |
|---|---|---|
| Data Storage | Dispersed across independent paper ledgers or isolated flat files. | Centralized within a unified, highly structured digital database system. |
| Data Redundancy | High; same data is frequently repeated in different files. | Minimized and tightly controlled through database normalization. |
| Data Consistency | Low; updating data in one place does not update it in others, causing conflicts. | High; centralized updates ensure consistent data across the entire system. |
| Security | Minimal; files can be easily mislaid, stolen, or damaged. | Robust; features user access levels, encryption, and password locks. |
| Data Searching | Slow, manual, and tedious process. | Lightning-fast retrieval using optimized query languages. |
C. Database Management System (DBMS)
A DBMS is specialized application software designed to store, manage, and organize data efficiently and securely. It acts as an intermediary link between database users and the raw database files.
Popular Examples of DBMS Software:
Recent Trends and Technologies in DBMS:
Features of a DBMS:
Summary of DBMS Benefits & Challenges:
Benefits: Easy and efficient storage, reduction in data duplication, consistency across all departments, multi-user concurrent access, and automatic backups.
Challenges: Requires technical knowledge to manage, high software licensing and hardware costs, security risks if misconfigured, and performance can slow down without proper indexing.
D. Relational Database Management System (RDBMS)
A Relational Database Management System (RDBMS) is a specific type of DBMS that organizes data into tables composed of rows and columns. What makes it “relational” is its ability to connect different tables together using common, shared data fields, eliminating the need to repeat information.
2.3 SQL Data Types
Data types define the specific kind of data that can be stored in each column of a database table, preventing entry errors and optimizing storage.
1. Numeric Data Types
2. Character (Text) Data Types
3. Date and Time Data Types
4. Boolean Data Type
2.4 Tables, Fields, and Records
In an RDBMS, a Table is the primary building block. It is a structured grid used to store related data in a clean format.
A. Fields (Columns / Attributes)
A Field is a vertical column in a database table that represents a specific property or attribute of the entity. Each field stores one specific type of data for all records in the table.
Example: In a Students table, Student_ID, Name, Class, and Date of Birth are fields:
| Student_ID | Name | Class | Date of Birth |
|---|---|---|---|
| 101 | Aarosh Pokharel | 10 | 2010-03-12 |
| 102 | Subigya Nepal | 10 | 2011-07-25 |
| 103 | Aarambha Gharti | 9 | 2013-11-10 |
B. Records (Rows / Tuples)
A Record is a single horizontal row that contains a complete, cohesive set of data for one specific entity in the table.
Example: A single record in the student database:
| S_ID | Name | Class | Date of Birth |
|---|---|---|---|
| 101 | Diwakar Bhandari | 10 | 2010 |
2.5 Relational Keys and Relationships
In a relational database, Keys are rules applied to columns. They uniquely identify rows and establish logical links across multiple tables.
1. Types of Keys
A. Primary Key (PK): A field (or combination) that uniquely identifies each record. It cannot contain duplicate values, cannot be NULL, and each table is strictly limited to exactly one primary key.
| StudentID (PK) | Name | Class | Age |
|---|---|---|---|
| 101 | Dipak | 10 | 15 |
| 102 | Rita | 10 | 14 |
| 103 | Gaurav | 9 | 14 |
B. Foreign Key (FK): A field in one table that references the Primary Key column of a different table. It acts as a link to enforce consistency.
Example: Table Students (StudentID is PK) and Table Library (StudentID is FK):
| BookID | BookTitle | StudentID (Foreign Key) |
|---|---|---|
| B_01 | Nepali History | 201 |
| B_02 | Harkabad | 201 |
| B_03 | Learn Python | 202 |
C. Composite Key: A primary key created by combining two or more columns to uniquely identify a record. This is used when no single column can guarantee uniqueness on its own.
| StudentID | Subject | Marks |
|---|---|---|
| 301 | Nepali | 85 |
| 301 | Social | 92 |
| 302 | Computer | 95 |
Analysis: Neither StudentID nor Subject is unique on its own. Combining them forms a Composite Key.
2. Types of Database Relationships
A. One-to-One ($1:1$): Each record in the first table is connected to exactly one record in the second table (e.g., A Person and their unique Passport).
B. One-to-Many ($1:M$): A single record in the first table is linked to multiple records in the second table (e.g., A Customer can place many Orders, but each Order belongs to only one customer).
C. Many-to-Many ($M:M$): Multiple records in the first table relate to multiple records in the second table. This requires a third “junction table” (e.g., Students and Courses).
2.6 Introduction to MySQL & Structured Query Language (SQL)
MySQL is a highly popular, open-source Relational Database Management System (RDBMS) that uses SQL (Structured Query Language) to manage and manipulate data.
SQL is divided into three distinct sub-languages:
MySQL Constraints
| Constraint | Functional Technical Description |
|---|---|
| PRIMARY KEY | Combines unique and NOT NULL validation. Ensures no duplicates or empty slots in the column. |
| FOREIGN KEY | Links one table to another, ensuring referential integrity. |
| NOT NULL | Prevents a column from accepting blank inputs. |
| UNIQUE | Guarantees all values in that column are completely different. |
| CHECK | Evaluates conditions before allowing data insertion (e.g., age > 18). |
| DEFAULT | Fills a column with a predefined value if no input is provided. |
Exercise 1: Choose the correct answer from the given options
Select an option to view the correct answer and justification.
Justification: A DBMS specializes in storing, retrieving, and manipulating data. Word processing is handled by document editors like Microsoft Word.
Justification: A primary key guarantees that every single row in a table is unique, with no duplicate or NULL values allowed.
Justification: A foreign key links to a primary key in another table, creating logical relational connections and maintaining referential integrity.
Justification: In a 1:M relationship, a parent record (Teacher) can relate to multiple children (Classes), but each child relates back to only one parent.
Justification: The
INSERT INTO statement is a Data Manipulation Language (DML) command used to add new records into a table.Justification: The
UPDATE command modifies and updates cell values in existing rows in a database table.Justification: The
WHERE clause evaluates conditional constraints, filtering the exact records retrieved by a query.Justification: The
LIKE clause leverages SQL wildcard symbols (% and _) to facilitate partial pattern-matching.Justification: The
DATE type is exclusively structured to store calendar dates in a YYYY-MM-DD template without time zones or clock hours.Justification:
VARCHAR(n) dynamically allocates only the required storage space up to a maximum of $n$ characters, making it highly memory-efficient.Justification:
CHAR(n) always allocates exactly $n$ characters by padding short strings with empty spaces, whereas VARCHAR(n) dynamically adjusts to the input length.Exercise 2: Write short answers to these questions
Information is data that has been structured, organized, and processed to convey clear context and meaning (e.g., “Aarosh scored 85 marks”).
Name).A DBMS (Database Management System) is the specialized application software (e.g., MySQL, Oracle) used to create, query, administer, and secure that database.
Real-World Example: A Customer and their Orders. One customer can place many orders over time, but each order is placed by only one customer.
CREATE, ALTER, DROP).INSERT, SELECT, UPDATE, DELETE).WHERE clause acts as a filter. It applies logical and conditional parameters to query statements, ensuring the database only retrieves rows that match the specific criteria.
UNIQUE, NOT NULL). They are vital because they block invalid, inaccurate, or duplicate data from being saved, keeping the database reliable and clean.
StudentID and Subject to record unique terminal exam scores).
Exercise 3: Write long answers to these questions
Advantages of DBMS:
Features of a Primary Key:
| Feature | Data Definition Language (DDL) | Data Manipulation Language (DML) |
|---|---|---|
| Primary Role | Manages the physical structure and schema layout of database objects. | Processes and manages the actual data records stored within those structures. |
| Permanence | Auto-Committing: Changes are saved permanently immediately upon execution. | Transactional: Operations can be undone (rolled back) before a commit. |
| Target Elements | Tables, databases, views, and indexes. | Rows, records, and specific field values. |
| SQL Commands | CREATE, ALTER, DROP, TRUNCATE, RENAME |
INSERT, SELECT, UPDATE, DELETE |
| Feature | Table | Query |
|---|---|---|
| Definition | A structured grid of rows and columns used to physically store data. | A structured question or command written in SQL used to interact with the database. |
| Function | Acts as the foundational storage container holding the actual database records. | Acts as an operational tool to retrieve, filter, manipulate, or delete those stored records. |
| Nature | Static and structural (remains on disk until physically altered or dropped). | Dynamic and temporary (runs on demand to output a temporary result-set). |
Types of Relationships:
Importance of Queries:
Purpose: The primary purpose of a report is to convert raw, complex, and fragmented datasets into readable, meaningful summaries. This empowers businesses, administrators, and users to analyze trends, understand system status, and make accurate, data-driven decisions.
Features of Reports:
SUM, AVG, COUNT) to display statistical totals.Exercise 4: Write down the SQL query for the following statement
CREATE DATABASE CompanyData;
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Salary DECIMAL(10,2)
);
ALTER TABLE Employees ADD Email VARCHAR(100);
ALTER TABLE Employees MODIFY COLUMN Salary DECIMAL(10,2) DEFAULT 25000;
ALTER TABLE Employees RENAME TO StaffMembers;
INSERT INTO StaffMembers (EmployeeID, FirstName, LastName, Salary) VALUES (101, 'Sampada', 'Bhattrai', 30000.50);
SELECT * FROM StaffMembers;
SELECT FirstName, Salary FROM StaffMembers;
UPDATE StaffMembers SET Salary = Salary + (Salary * 0.10);
DELETE FROM StaffMembers WHERE EmployeeID = 103;
DELETE FROM StaffMembers;
📚 Also Read: Class 10 SEE Notes
Computer Science Units
Other Subjects
