Chapter5_Database_System
Chapter5_Database_System
Chapter 5
Database System
Page 1
Chapter 5: Database System | Shubha Yatra Academy
What is Data?
Data refers to raw facts, figures, or values that have no meaning on their own without context. Data is
essentially unprocessed information that, when organized and combined with context, becomes useful and
meaningful.
• Examples of Data: A number like 12345, a name like "John Doe", a date like 2024-12-16, a
temperature reading like 37°C
• Key Point: Data alone is meaningless. For example, "100" is just a number. But when we say
"100 marks in Math", it becomes meaningful information.
Remember
Data = Raw facts without context
Information = Data + Context + Meaning
Example: "25" is data. "Age: 25 years" is information.
What is a Database?
A database is a structured and organized collection of related data that is stored in a way that allows
for easy access, management, retrieval, and updating. It organizes data systematically so that users can
efficiently store and retrieve information when needed.
• Example: A customer database might store information like customer names, contact numbers,
email addresses, and purchase histories — all organized in tables.
• Example: A school database stores student names, roll numbers, grades, attendance records, and
fee details.
• Example: A hospital database stores patient records, doctor details, appointment schedules, and
billing information.
Feature Description
Organized Data is arranged in tables, rows, and columns for easy access.
Shared Multiple users can access the same database at the same time.
Integrated Data from different sources is combined into a single system.
Persistent Data remains stored even when the computer is turned off.
Secure Access to data can be restricted to authorized users only.
Page 2
Chapter 5: Database System | Shubha Yatra Academy
Functions of a DBMS
Function Description
Data Storage Organizes and stores data efficiently in a structured format using tables.
Executes commands to retrieve, insert, modify, or delete data based on user
Query Execution
input. Users can write SQL queries or use graphical tools.
Provides access control features like user accounts, passwords, and
Security
permissions to protect data from unauthorized access.
Ensures the data is accurate, consistent, and follows predefined rules
Data Integrity
(constraints) across the system.
Creates backup copies of the database and can restore data in case of system
Backup & Recovery
failure or data loss.
Manages simultaneous access by multiple users, ensuring data consistency
Concurrency Control
and preventing conflicts.
Changes to the database structure do not affect the applications that use the
Data Independence
data.
Page 3
Chapter 5: Database System | Shubha Yatra Academy
Exam Tip
DBMS functions are frequently asked in exams. Remember: Storage, Query, Security, Integrity, Backup,
Concurrency, Independence.
MS Access is the DBMS tool covered in this syllabus.
In a relational database (like Microsoft Access), data is organized into tables. Understanding the key
components of a table is essential for working with any database system.
Page 4
Chapter 5: Database System | Shubha Yatra Academy
In this table: Student_ID is the Primary Key, each row is a Record, and each column (Name, Age, etc.) is
a Field.
Relationships
A relationship is a link or connection between two or more tables based on a common field.
Relationships allow data in different tables to be connected, reducing duplication and improving data
organization.
Types of Relationships:
MS Access Tip
In MS Access, you create relationships using the Relationships window.
Go to Database Tools tab > Relationships to open this window.
Drag a field from one table and drop it on the matching field in another table.
Indexing
An index is a special data structure that speeds up the retrieval of data from a database table. It works
similar to an index in a textbook — instead of reading every page, you look up the index to find the exact
page quickly.
Page 5
Chapter 5: Database System | Shubha Yatra Academy
Quick Comparison
Without Index: Database scans ALL records to find a match (slow for large tables).
With Index: Database jumps directly to matching records (fast lookup).
Think of it like a book: without an index, you flip through every page; with an index, you go directly to the
right page.
Database applications are software tools that interact with databases for storing, managing, and
analyzing data. These applications make it easier to create, modify, and retrieve data, and they provide
user-friendly interfaces for interacting with the database.
Microsoft Access is one of the most popular desktop database applications. It is part of the Microsoft
Office suite and provides a graphical interface for creating and managing databases without needing to
write complex code.
Important
MS Access uses the .accdb file format (or older .mdb format).
It is a Relational Database Management System (RDBMS).
It supports SQL (Structured Query Language) for advanced queries.
Page 6
Chapter 5: Database System | Shubha Yatra Academy
Every field in a database table must have a data type assigned to it. The data type determines what kind of
values can be stored in that field. Choosing the correct data type is important for data accuracy, storage
efficiency, and validation.
Page 7
Chapter 5: Database System | Shubha Yatra Academy
Creating a Table
Tables are the foundation of any database. In MS Access, you can create tables in two ways:
Modifying a Table
You can modify an existing table structure to add, change, or remove fields:
1. Open the table in Design View (right-click the table name > Design View).
2. To add a new field: Click on an empty row and type the new field name and select its data type.
3. To change a data type: Click on the Data Type column of the field you want to modify and
select a new type.
4. To rename a field: Click on the Field Name and edit it directly.
5. To change field size: Adjust the Field Size property in the Field Properties panel at the bottom.
6. To delete a field: Right-click on the field row and select "Delete Rows".
7. Save the changes (Ctrl + S).
Page 8
Chapter 5: Database System | Shubha Yatra Academy
Deleting a Table
If a table is no longer needed, you can remove it from the database:
1. In the Navigation Pane (left sidebar), find the table you want to delete.
2. Right-click on the table name.
3. Select "Delete" from the context menu.
4. Confirm the deletion when prompted.
Warning
Deleting a table permanently removes all its data and structure.
If other tables have relationships with the deleted table, those relationships will also be broken.
Always create a backup before deleting important tables.
Page 9
Chapter 5: Database System | Shubha Yatra Academy
Relationships connect tables together based on common fields. This is a core feature of relational
databases like MS Access. By establishing relationships, you can:
• Avoid data duplication (store data in one place and reference it from other tables)
• Ensure data consistency (changes in one table are reflected in related tables)
• Create powerful queries that combine data from multiple tables
Referential Integrity
Referential Integrity is a set of rules that ensures relationships between tables remain consistent.
When enforced, you cannot add a record in the foreign table that has no matching record in the primary table.
Example: You cannot add an order for Customer_ID = 999 if no customer with ID 999 exists.
Page 10
Chapter 5: Database System | Shubha Yatra Academy
Formatting
Formatting controls how data is displayed to the user. It does not change the actual stored data — it only
changes how it appears on screen or in printed reports.
How to Set Format in MS Access: Open the table in Design View > Select the field > In the Field
Properties panel at the bottom, set the Format property.
Page 11
Chapter 5: Database System | Shubha Yatra Academy
Page 12
Chapter 5: Database System | Shubha Yatra Academy
Once tables are created, you need to add, edit, and remove data. In MS Access, data manipulation is done
primarily through the Datasheet View or through Forms.
Auto-Save
Unlike Word or Excel, MS Access automatically saves data as you enter it.
You do NOT need to press Ctrl+S to save records.
However, table structure changes (in Design View) need to be saved manually.
Caution
Deleting a record is PERMANENT in MS Access. You cannot undo a deletion after moving to another
record.
Page 13
Chapter 5: Database System | Shubha Yatra Academy
If Referential Integrity is enforced and Cascade Delete is enabled, deleting a record may also delete related
records in other tables.
Always double-check before confirming a deletion.
Page 14
Chapter 5: Database System | Shubha Yatra Academy
1) Queries
Queries are used to retrieve, filter, sort, and analyze specific data from one or more tables based on
certain criteria. They are one of the most powerful features of a database.
Creating a Query
Method 1: Query Design View (Graphical)
a) Go to Create tab > Query Design.
b) The Show Table dialog appears. Add the table(s) you want to query, then close the dialog.
c) In the Query Design grid at the bottom, select the fields you want to include by double-
clicking them or dragging them down.
d) In the Criteria row, enter conditions to filter data (e.g., >500 for amounts greater than 500, or
"Kathmandu" for a city field).
e) In the Sort row, choose Ascending or Descending to sort results.
f) Click Run (!) on the Design tab to execute the query and see results.
g) Save the query with a meaningful name (e.g., "CustomersInKathmandu").
Page 15
Chapter 5: Database System | Shubha Yatra Academy
• SELECT Name, Age FROM Students WHERE Age >= 18; — Gets names and ages of students
18 or older
• SELECT * FROM Orders WHERE Amount > 500 ORDER BY Amount DESC; — Orders
above 500, sorted by amount (highest first)
Modifying a Query
• Right-click the query name in the Navigation Pane > Design View.
• Change the fields, criteria, or sort order as needed.
• Run the query again to see updated results.
• Save the changes.
Deleting a Query
• Right-click the query name in the Navigation Pane > Delete.
• Confirm the deletion. (This only removes the query, NOT the data in the tables.)
Query Tip
Deleting a query does NOT delete any data. Queries are just saved questions/commands.
You can use wildcards in criteria: * (any characters), ? (single character), # (single digit).
Example criteria: Like "K*" finds all records starting with K.
Page 16
Chapter 5: Database System | Shubha Yatra Academy
2) Forms
Forms provide a user-friendly graphical interface for entering, editing, and viewing data in a database.
Instead of working directly with the table grid, forms allow users to interact with one record at a time in a
visually organized layout.
Creating a Form
Method 1: Quick Form (Auto-generated)
a) Select the table you want to base the form on (click it once in the Navigation Pane).
b) Go to Create tab > Form.
c) MS Access automatically creates a form with all the fields from the selected table.
d) Save the form with a descriptive name.
Modifying a Form
• Open the form in Layout View (quick visual changes) or Design View (full control).
• Add, remove, or rearrange fields and controls.
• Change colors, fonts, sizes, and alignment.
• Add buttons, dropdown lists, or combo boxes.
• Save the changes.
Page 17
Chapter 5: Database System | Shubha Yatra Academy
Deleting a Form
• Right-click the form name in the Navigation Pane > Delete.
• Confirm the deletion. (This only removes the form, NOT the underlying data.)
Page 18
Chapter 5: Database System | Shubha Yatra Academy
3) Reports
Reports are used to present data in a formatted, printable, and professional-looking view. They are
designed for displaying, summarizing, and analyzing data for output purposes (printing, PDF export, or
screen display).
Creating a Report
Method 1: Quick Report (Auto-generated)
• Select the table or query in the Navigation Pane.
• Go to Create tab > Report.
• MS Access automatically generates a report with all fields.
• Save and name the report.
Modifying a Report
• Open the report in Layout View or Design View.
• Change layout, grouping, sorting, or add/remove fields.
• Add calculated fields (e.g., =Sum([Amount]) for totals).
• Change colors, fonts, and formatting.
• Save the changes.
Page 19
Chapter 5: Database System | Shubha Yatra Academy
Deleting a Report
• Right-click the report name in the Navigation Pane > Delete.
• Confirm the deletion. (Only the report is removed, not the underlying data.)
Feature Report
Purpose Display and print formatted data summaries
Data Editing No (read-only)
User Interface Professional printable layout
Output Printed or exported documents (PDF, paper)
Based On Tables or queries
Page 20