📊 Chapter 9: Database

Complete Study Notes for O/L ICT Students

🎯 Learning Objectives

  • ✓ Definition of database
  • ✓ Advantages of using a database
  • ✓ Special characteristics of a database
  • ✓ Using fields to create tables
  • ✓ Identifying key fields
  • ✓ Relational databases
  • ✓ Relationships between tables
  • ✓ Using queries to get data
  • ✓ Using data forms
  • ✓ Using reports to furnish information

9.1 Database Concept

Database: A collection of organized data that can be efficiently stored, retrieved, and managed.

Types of Databases

1. Manual Database: Data written and stored on paper (e.g., phone book)

2. Electronic Database: Data stored on electronic medium (e.g., computer, mobile phone)

📱 Real-World Example: Phone Book

A phone book is a simple database where:

  • Names are organized alphabetically
  • Each contact has a name and phone number
  • Information can be quickly retrieved when needed
Manual Phone Book

Figure 9.1 - Manual Phone Book

Electronic Phone Book

Figure 9.2 - Electronic Phone Book

9.1.1 Advantages of Databases

  • More efficient in retrieving information: Data is properly organized in tables, making it quick to find required information.
  • Easy to obtain copies: Electronic databases can be copied very easily.
  • Smaller physical space: Electronic databases require much less physical space compared to manual databases.
  • Efficient data analysis: Only necessary data can be selected and processed.
  • Data can be shared: The same database can be used in different application software.
  • Independence of data: Database tables can be updated without changes to the application software.

9.1.2 Features of a Database

  • Minimal data redundancy: Reduces storing the same data in multiple places.
  • Data consistency: Ensures the same data across different tables is accurate and uniform.
  • Increases efficiency: Properly organized tables make saving and reading data faster.
  • Increases accuracy: Minimizing redundancy maintains data consistency and accuracy.
  • Increases validity: Field properties ensure data entered meets specific criteria.
  • Security: Unauthorized access can be controlled using passwords and encryption.

🔍 Example: Data Redundancy Problem

Problem: If student name "Firosa Lai" is stored in both admission table and library table, changing it to "Firosa Rafeeq" requires updating both tables.

Table 9.1 - Admission Table (Before)
Student Number Name Date of Birth Date of Admission
100 Manoj Dayarathne 2/9/2008 1/1/2014
101 Firosa Lai 4/2/2008 1/1/2014

Solution: Use relational database with primary and foreign keys to store name only once.

📝 Important Note: Data encryption translates data in such a way that unauthorized personnel cannot read it, increasing security.
Data Encryption Example

Figure 9.4 - Data Encryption

9.1.3 Electronic and Manual Databases

Table 9.4 - Comparison of Manual and Electronic Databases
Manual Database Electronic Database
Less efficient More efficient
Less accurate More accurate
Less credible More credible
Difficult to analyze data Easy to analyze data
Must present in order of input Can change data input order
Difficult to delete unnecessary data Easy to delete unnecessary data
Difficult to update data Easy to update data
More space needed Very small space needed
More manpower needed Less manpower needed

9.1.4 Introduction to Relational Database

Field: A single piece of information (a column in a table)

Record: A collection of fields related to one person or object (a row in a table)

Data Table: A collection of records

Relational Database: A collection of related tables

Database Structure Hierarchy:

Field 1 + Field 2 + Field 3 + ... = Record

Record 1 + Record 2 + Record 3 + ... = Table

Table 1 + Table 2 + Table 3 + ... = Relational Database

Database Structure Hierarchy

Figure 9.5 - Relational Database Structure

📚 Example: Student Records

Table 9.6 - Student Records
Admission No Name Date of Birth Gender Telephone No
1426 Kavindu Prabashwara 2005.05.23 Male 0352287571
1427 Meenadevi Ramanathan 2005.08.12 Female 0352235696
1428 Mohommad Malikkar 2005.02.07 Male 0352815402

In this table:

  • Each column represents a field
  • Each row represents a record
  • There are 5 fields and 3 records

9.1.5 Primary Key

Primary Key: A column (or combination of columns) that uniquely identifies each record in a table.
Special Attributes of a Primary Key:
  • Should not be empty (mandatory)
  • No duplicate values (must be unique)
  • Usually underlined in table design

📖 Example: Book Table

Table 9.7 - Book Table
Accession No Title Author's Name Price Number of Books
2131 Let's Access Internet Mahesh Gankanda Rs. 275.00 10
2132 Computer Studies Suranimala Basnayaka Rs. 300.00 5
2133 Essay Writing Nimali Bogoda Rs. 225.00 12

Analysis:

  • ✓ Accession No: Unique for each book - Best for Primary Key
  • ✗ Title: Can have duplicates (same book name by different authors)
  • ✗ Author's Name: One author can write multiple books
  • ✗ Price: Different books can have same price
  • ✗ Number of Books: Multiple books can have same quantity

🔑 Common Primary Key Examples:

  • National Identity Card Number
  • School Admission Number
  • Employee ID
  • Product Code
  • Customer ID

9.1.6 Composite Primary Key

Composite Primary Key: A primary key that consists of two or more columns to uniquely identify a record.

⚽ Example: Sports Table

Table 9.9 - Sports Table
Year Sport Captain Vice Captain
2013 Cricket Rashmi Senarathne Mubharak Husein
2013 Football Jaliya Saranga Vinothen Raj
2014 Cricket Mubharak Husein Bhanu Dayarathne
2014 Football Jaliya Saranga Ahammed Nawas

Why Composite Key?

  • Year alone: Has duplicates (2013, 2014)
  • Sport alone: Has duplicates (Cricket, Football)
  • Year + Sport together: Unique combination!

Composite Primary Key = Year + Sport

9.1.7 Foreign Key

Foreign Key: A field (or combination of fields) in one table that refers to the primary key in another table, creating a relationship between the tables.
Special Features of a Foreign Key:
  • Builds a connection between two tables
  • The related data of the primary key field exists in the other table
  • Foreign key of one table is the primary key of another table

🔗 Example: Student and Subject Tables

Table 9.11 - Student Table
Registration Number Name Date of Birth Date of Admission
100 Manoj Dayarathne 2/9/2014 1/1/2014
101 Firosa Rafeeq 4/2/2014 1/1/2014
Table 9.12 - Subject Table
Candidate No Maths Science Sinhala English Registration No
449683 B A C C 100
449697 A B B A 101

In this example:

  • Registration Number is the Primary Key of Student Table
  • Registration Number is the Foreign Key of Subject Table
  • Candidate No is the Primary Key of Subject Table
Foreign Key Relationship

Figure 9.6 - Primary Key and Foreign Key Relationship

Disadvantages of Data Duplication

⚠️ Problems with Data Duplication:

  1. Inability to select a primary key field: Duplicate data makes it difficult to maintain record identity.
  2. Inability to analyze data properly: Same student counted multiple times leads to incorrect analysis.
  3. Reduced efficiency: More time spent entering the same data repeatedly.
  4. High possibility of inaccurate data: Errors can occur when entering same data multiple times (e.g., "Malikkar" vs "Malakkar").
  5. Difficult to input data: Must enter name, date of birth repeatedly for each record.
  6. Errors in deleting data: Multiple records for one student can lead to deletion mistakes.
  7. Difficult to update data: Must update each duplicate record separately.

✅ Solution: Split into Related Tables

Table 9.15 - Student Table
Admission No Name Date of Birth
1426 Kavindu Prabashwara 2005.05.23
1427 Meenadevi Ramanathan 2005.08.12
1428 Mohommad Malikkar 2005.02.07
Table 9.16 - Marks Table
Admission No Marks Term Year
1426 69 1 2014
1427 82 1 2014
1426 79 2 2014

Benefits:

  • ✓ Student information stored only once
  • ✓ No data duplication
  • ✓ Easier to update student details
  • ✓ Clear primary key (Admission No in Student Table)
  • ✓ Foreign key (Admission No) links the tables

9.2 Data Types

Data Type: A type of data related to one field that determines what kind of data can be stored and how it can be used.

Common Data Types:

Data Type Description Examples
Numeric Used for calculations
  • Integer Whole numbers (positive or negative) 12, -23, 0
  • Real Numbers with decimal places 8.125, -2.64, 4.00
Text Letters, numbers, or special characters (not for calculations) 889534731V, 0112785123
Currency Monetary values $12.45, Rs. 35.00
Date/Time Dates and times 12/23/2013, 7:35 AM
Boolean Logical values only True, False
💡 Important: Although telephone numbers contain digits, they should be stored as Text data type because:
  • They are not used for calculations
  • They may contain special characters (e.g., 0112-985123)
  • Leading zeros must be preserved (e.g., 0352287571)

📝 Example: Choosing Data Types

Table 9.17 - Field Data Types
Field Data Type Reason
Admission Number Text Not used for calculations, may have letters
Date of Admission Date/Time Stores date information
Subject Code Text Alphanumeric identifier
Doctor's Fee Currency Monetary value
Department Name Text Textual information
Number of Passengers Integer Whole number for counting
Is Registered? Boolean Yes/No or True/False value

9.4 Creating a Relational Database

9.4.1 Types of Relationships

1. One-to-One Relationship (1:1)

A relationship where one record in Table A relates to only one record in Table B, and vice versa.

Example: Student and Scholarship Marks

One-to-One Relationship

Figure 9.11 - One-to-One Relationship Diagram

Characteristics:

  • Each student has exactly one scholarship exam record
  • Each scholarship record belongs to exactly one student
  • Primary Key: Admission No (Student Table), Index No (Marks Table)
  • Foreign Key: Admission No in Marks Table

2. One-to-Many Relationship (1:M)

A relationship where one record in Table A can relate to multiple records in Table B, but each record in Table B relates to only one record in Table A.

Example: Student and Fee Payments

One-to-Many Relationship

Figure 9.12 - One-to-Many Relationship Diagram

Characteristics:

  • One student can make multiple fee payments
  • Each payment belongs to exactly one student
  • Primary Key: Admission No (Student Table), Receipt No (Fees Table)
  • Foreign Key: Admission No in Fees Table
Features of One-to-Many Relationship
Table A (Parent) Table B (Child/Related)
One record can relate to multiple records in Table B Each record relates to only one record in Table A
Can have records not related to Table B Cannot have records not related to Table A
Primary key data cannot duplicate Foreign key data can duplicate

3. Many-to-Many Relationship (M:N)

A relationship where multiple records in Table A can relate to multiple records in Table B, and vice versa. This requires a junction table to implement.

Example: Students and Sports

Many-to-Many Relationship

Figure 9.13 - Many-to-Many Relationship Converted to Two One-to-Many

Characteristics:

  • One student can participate in multiple sports
  • One sport can have multiple students
  • Requires a junction table (Students Sports Table)
  • Composite Primary Key in junction table: Admission No + Sport No
Student Table
Admission No Name Date of Birth
1426 Kavindu Prabashwara 2005.05.23
1428 Mohommad Malikkar 2005.02.07
Students Sports Table (Junction Table)
Admission No Sport No Team
1426 S001 A
1426 S002 A
1428 S001 B
Sports Table
Sport No Sport Number of Members
S001 Cricket 11
S002 Football 16

🖥️ 10 Practical Examples with Microsoft Access

Example 1: Creating a Simple Library Database

Steps:

  1. Open Microsoft Access
  2. Create → Table Design
  3. Add fields:
    • Accession_No (Text) - Primary Key
    • Book_Title (Text)
    • Author_Name (Text)
    • Price (Currency)
    • Quantity (Number)
  4. Right-click Accession_No row → Primary Key
  5. Save table as "Books"
Library Table Design

Library Table in Design View

Example 2: Student Registration System

Create Student Table:

Field Name Data Type Properties
Student_ID Text Primary Key, Field Size: 10
Full_Name Text Field Size: 50
Date_of_Birth Date/Time Format: Short Date
Email Text Field Size: 50
Phone_Number Text Field Size: 15
Student Table Design

Student Registration Table

Example 3: Creating a One-to-Many Relationship

Tables: Customer and Orders

Customer Table:

  • Customer_ID (Text) - Primary Key
  • Customer_Name (Text)
  • City (Text)

Orders Table:

  • Order_ID (Text) - Primary Key
  • Order_Date (Date/Time)
  • Amount (Currency)
  • Customer_ID (Text) - Foreign Key

Creating Relationship:

  1. Database Tools → Relationships
  2. Add both tables
  3. Drag Customer_ID from Customer table to Customer_ID in Orders table
  4. Check "Enforce Referential Integrity"
  5. Check "Cascade Update Related Fields"
  6. Check "Cascade Delete Related Records"
  7. Click Create
One-to-Many Relationship

Customer-Orders Relationship

Example 4: Product Inventory Database

Product Table Fields:

Field Name Data Type Description
Product_Code Text Primary Key (e.g., "PROD001")
Product_Name Text Name of the product
Category Text Product category
Unit_Price Currency Price per unit
Stock_Quantity Number (Integer) Available quantity
Reorder_Level Number (Integer) Minimum stock level
Product Inventory Table

Product Inventory System

Example 5: Creating a Query to Filter Data

Task: Find all books with price less than Rs. 300

Steps:

  1. Create → Query Design
  2. Add the "Books" table
  3. Select fields: Accession_No, Book_Title, Author_Name, Price
  4. In the "Criteria" row under Price, type: <300
  5. Run the query
Query Design View

Query to Filter Books by Price

Example 6: Creating a Form for Data Entry

Task: Create a user-friendly form for entering student data

Steps:

  1. Select the Student table
  2. Create → Form
  3. Access automatically creates a form
  4. Switch to Design View to customize
  5. Add a title label "Student Registration Form"
  6. Save the form
Student Registration Form

Student Data Entry Form

Example 7: Creating a Report for Printing

Task: Create a report showing all students sorted by name

Steps:

  1. Create → Report Wizard
  2. Select Student table
  3. Add fields: Student_ID, Full_Name, Date_of_Birth, Email
  4. Sort by: Full_Name (Ascending)
  5. Choose layout: Tabular
  6. Give title: "Student Directory"
  7. Finish
Student Directory Report

Student Directory Report

Example 8: Query with Calculations

Task: Calculate total inventory value (Unit_Price × Stock_Quantity)

Steps:

  1. Create → Query Design
  2. Add Product table
  3. Add fields: Product_Code, Product_Name, Unit_Price, Stock_Quantity
  4. In a new column, type: Total_Value: [Unit_Price]*[Stock_Quantity]
  5. Run the query
Query with Calculation

Inventory Value Calculation Query

Example 9: Using Parameter Query

Task: Search for students by entering their name

Steps:

  1. Create → Query Design
  2. Add Student table
  3. Select all fields
  4. In Criteria row under Full_Name, type: [Enter Student Name:]
  5. Run the query - a dialog box will appear
  6. Enter a name to search
Parameter Query

Parameter Query for Student Search

Example 10: Many-to-Many Relationship Implementation

Task: Create a system where students can enroll in multiple courses and courses can have multiple students

Table 1: Students

  • Student_ID (Primary Key)
  • Student_Name

Table 2: Courses

  • Course_ID (Primary Key)
  • Course_Name

Table 3: Enrollments (Junction Table)

  • Enrollment_ID (Primary Key)
  • Student_ID (Foreign Key)
  • Course_ID (Foreign Key)
  • Enrollment_Date

Creating Relationships:

  1. Create two one-to-many relationships:
    • Students to Enrollments (Student_ID)
    • Courses to Enrollments (Course_ID)
  2. Enforce referential integrity for both
Many-to-Many Implementation

Student-Course Enrollment System

📝 10 Practical Activities

Activity 1: Create a Personal Contact Database

Task: Create a database to store contact information of your friends and family.

Requirements:

  • Create a table with fields: Contact_ID, Name, Phone, Email, Birthday
  • Set appropriate data types
  • Define primary key
  • Enter at least 10 contacts

Activity 2: School Library System

Task: Design a complete library management system.

Requirements:

  • Create three tables: Books, Members, Borrowing
  • Establish proper relationships
  • Create a query to show borrowed books
  • Design a form for book borrowing

Activity 3: Restaurant Menu Database

Task: Create a database for a restaurant menu.

Requirements:

  • Fields: Item_Code, Item_Name, Category, Price, Available
  • Create a query to show items by category
  • Create a report showing the complete menu

Activity 4: School Event Management

Task: Design a database to manage school events and participants.

Requirements:

  • Create tables: Events, Students, Participation
  • Implement many-to-many relationship
  • Create query to show event participants

Activity 5: Marks Management System

Task: Create a database to store student marks for different subjects.

Requirements:

  • Tables: Students, Subjects, Marks
  • Create a query to calculate average marks
  • Generate a report card

Activity 6: Hospital Appointment System

Task: Design a simple appointment booking system.

Requirements:

  • Tables: Patients, Doctors, Appointments
  • Include fields for appointment date and time
  • Create query to show daily appointments

Activity 7: Online Store Database

Task: Create a database for an online store.

Requirements:

  • Tables: Products, Customers, Orders, Order_Details
  • Establish all necessary relationships
  • Create query to calculate total sales

Activity 8: Movie Collection Database

Task: Manage your personal movie collection.

Requirements:

  • Fields: Movie_ID, Title, Genre, Year, Rating, Watched
  • Create query to filter by genre
  • Create form for adding new movies

Activity 9: Sports Club Management

Task: Create a database for a sports club.

Requirements:

  • Tables: Members, Sports, Participation
  • Track membership fees and payment dates
  • Create report showing active members

Activity 10: Classroom Attendance Tracker

Task: Design a database to track student attendance.

Requirements:

  • Tables: Students, Attendance_Records
  • Fields for date, present/absent status
  • Create query to calculate attendance percentage
  • Generate monthly attendance report

❓ 20 Questions & Answers

Q1. What is a database? Define with an example.

Answer: A database is a collection of organized data that can be efficiently stored, retrieved, and managed.

Example: A phone book that contains names and phone numbers organized alphabetically is a simple database. The electronic version stored in a mobile phone is an electronic database where contacts can be quickly searched and retrieved.

Q2. List and explain five advantages of using electronic databases over manual databases.

Answer:

  1. More efficient in retrieving information: Data organized in tables can be searched and found very quickly.
  2. Easy to obtain copies: Electronic databases can be backed up and copied easily.
  3. Smaller physical space: Large amounts of data can be stored on small electronic devices.
  4. Efficient data analysis: Specific data can be selected and processed for analysis.
  5. Data independence: Database structure can be changed without affecting application software.

Q3. What is data redundancy? Explain with an example why it should be minimized.

Answer: Data redundancy occurs when the same data is stored in multiple places in a database.

Example: If a student's name "Firosa Lai" is stored in both the admission table and library table, changing it to "Firosa Rafeeq" requires updating both tables. This:

  • Wastes storage space
  • Increases chances of errors
  • Reduces efficiency
  • Can lead to data inconsistency if one instance is updated but another is missed

Q4. Define the following terms: Field, Record, and Table with examples.

Answer:

  • Field: A single piece of information (a column in a table). Example: "Student_Name", "Date_of_Birth"
  • Record: A collection of related fields for one entity (a row in a table). Example: One student's complete information including name, ID, birth date, etc.
  • Table: A collection of records organized in rows and columns. Example: A "Students" table containing records of all students with their details.

Q5. What is a Primary Key? What are its special characteristics?

Answer: A Primary Key is a column (or combination of columns) that uniquely identifies each record in a table.

Special Characteristics:

  • Cannot be empty: Must always have a value (mandatory)
  • Must be unique: No duplicate values allowed
  • Unchanging: Should not change frequently

Examples: National ID Number, School Admission Number, Employee ID

Q6. Explain Composite Primary Key with an example.

Answer: A Composite Primary Key is a primary key made up of two or more columns that together uniquely identify a record.

Example: In a Sports Captain table:

  • Year alone has duplicates (2013, 2013, 2014, 2014)
  • Sport alone has duplicates (Cricket, Cricket, Football, Football)
  • But Year + Sport combination is unique (2013-Cricket, 2013-Football, 2014-Cricket, 2014-Football)

Therefore, Composite Primary Key = Year + Sport

Q7. What is a Foreign Key? How does it create relationships between tables?

Answer: A Foreign Key is a field (or combination of fields) in one table that refers to the Primary Key in another table.

How it creates relationships:

  • Links two tables together
  • The Foreign Key in one table matches the Primary Key in another table
  • Maintains referential integrity
  • Enables data retrieval from multiple related tables

Example: Student_ID is the Primary Key in the Students table and Foreign Key in the Marks table, creating a relationship between them.

Q8. Why should telephone numbers be stored as Text data type instead of Number data type?

Answer: Telephone numbers should be stored as Text because:

  1. Not used for calculations: We never add, subtract, or perform mathematical operations on phone numbers
  2. Leading zeros: Numbers like 0352287571 would lose the leading zero if stored as Number (becoming 352287571)
  3. Special characters: Phone numbers may contain hyphens, spaces, or parentheses (e.g., 0112-985123, (011) 2345678)
  4. International format: May include plus signs and country codes (e.g., +94 11 2345678)

Q9. List and explain the common data types used in databases.

Answer:

  1. Text: Stores letters, numbers, and special characters. Not for calculations. Example: Names, addresses, ID numbers
  2. Number (Integer): Stores whole numbers. Example: Age, quantity, count
  3. Number (Real/Decimal): Stores numbers with decimal places. Example: Height, weight, percentages
  4. Currency: Stores monetary values. Example: Prices, salaries, fees
  5. Date/Time: Stores dates and times. Example: Birth date, appointment time
  6. Boolean (Yes/No): Stores only True/False values. Example: Registered?, Active?, Passed?

Q10. Explain the three types of relationships in relational databases with examples.

Answer:

  1. One-to-One (1:1): One record in Table A relates to only one record in Table B.
    Example: One student has one scholarship exam record; one exam record belongs to one student.
  2. One-to-Many (1:M): One record in Table A relates to multiple records in Table B.
    Example: One student can make multiple fee payments; each payment belongs to one student.
  3. Many-to-Many (M:N): Multiple records in Table A relate to multiple records in Table B.
    Example: One student can enroll in multiple courses; one course can have multiple students. Requires a junction table.

Q11. What is data encryption? Why is it important for database security?

Answer: Data encryption is the process of translating data into a coded format that unauthorized personnel cannot read or understand.

Importance:

  • Protects sensitive information: Personal details, passwords, financial data remain secure
  • Prevents unauthorized access: Even if someone gains access to the database file, they cannot read encrypted data
  • Maintains confidentiality: Ensures privacy of individuals whose data is stored
  • Compliance: Meets legal and regulatory requirements for data protection

Q12. List and explain five disadvantages of data duplication.

Answer:

  1. Inability to maintain record identity: Cannot select a proper primary key field when data is duplicated
  2. Incorrect data analysis: Same person counted multiple times leads to wrong statistics
  3. Reduced efficiency: More time spent entering the same data repeatedly
  4. Increased inaccuracy: Spelling errors (e.g., "Malikkar" vs "Malakkar") can occur when entering same data multiple times
  5. Difficult to update: Must update every duplicate instance, increasing chance of missing some

Q13. What is a relational database? How is it structured?

Answer: A relational database is a collection of related tables that are connected through primary and foreign keys.

Structure:

  • Fields: Individual data items (columns)
  • Records: Collection of fields (rows)
  • Tables: Collection of records
  • Relationships: Connections between tables using keys

Hierarchy: Fields → Records → Tables → Relational Database

Q14. Explain the concept of referential integrity in databases.

Answer: Referential integrity is a database rule that ensures relationships between tables remain consistent.

Key Principles:

  • Cannot add records: Cannot add a record in the related table with a foreign key value that doesn't exist in the primary table
  • Cannot delete records: Cannot delete a record from the primary table if related records exist in the related table
  • Cascade updates: When a primary key value is updated, all related foreign key values are automatically updated
  • Cascade deletes: When a record is deleted from the primary table, all related records in the related table are automatically deleted

Q15. What is a Database Management System (DBMS)? Name three examples.

Answer: A Database Management System (DBMS) is a collection of programs that enables users to create, maintain, and manage databases efficiently.

Components/Objects of DBMS:

  • Tables
  • Queries
  • Forms
  • Reports

Examples:

  1. Microsoft Access - by Microsoft Corporation
  2. LibreOffice Base - by The Document Foundation
  3. Oracle Database - by Oracle Corporation

Q16. What is a query? Why is it used in databases?

Answer: A query is a request for specific information from one or more database tables.

Uses of Queries:

  • Filter data: Display only records that meet certain criteria (e.g., students scoring above 60 marks)
  • Sort data: Arrange records in ascending or descending order
  • Calculate data: Perform calculations like totals, averages, counts
  • Combine data: Retrieve data from multiple related tables
  • Update data: Modify multiple records at once

Example: A query to find all books in the library with price less than Rs. 300.

Q17. What is the purpose of a form in a database?

Answer: A form provides a user-friendly interface for entering, viewing, and editing data in a database.

Purposes:

  • Easy data entry: Presents fields in a clear, organized layout rather than a spreadsheet-like view
  • Data validation: Can include validation rules to ensure correct data entry
  • User-friendly: Makes database accessible to non-technical users
  • Control access: Can limit which fields users can see or edit
  • Navigation: Provides buttons and controls to move between records

Example: A student registration form showing one student's details at a time with clear labels and input boxes.

Q18. What is a report? How is it different from a query?

Answer: A report is a formatted presentation of database information designed for printing or viewing.

Differences from Query:

Query Report
Used to retrieve data Used to present data
Data can be edited Data cannot be edited
Basic formatting Professional formatting with headers, footers, grouping
Not designed for printing Optimized for printing
Can perform calculations Can display calculated totals, subtotals, summaries

Q19. How do you implement a Many-to-Many relationship in a database?

Answer: A Many-to-Many relationship is implemented using a junction table (also called bridge table or linking table).

Steps:

  1. Create the two main tables (e.g., Students and Sports)
  2. Create a junction table (e.g., Students_Sports)
  3. Include foreign keys from both main tables in the junction table
  4. The composite primary key of the junction table consists of both foreign keys
  5. Create two one-to-many relationships:
    • Students to Students_Sports (one-to-many)
    • Sports to Students_Sports (one-to-many)

Result: The many-to-many relationship is converted into two one-to-many relationships.

Q20. Compare and contrast manual and electronic databases (list at least 5 differences).

Answer:

Aspect Manual Database Electronic Database
Efficiency Less efficient - slow to find information More efficient - quick searches
Accuracy Less accurate - prone to human error More accurate - validation rules prevent errors
Storage Space Requires large physical space Requires minimal physical space
Data Updates Difficult to update - manual corrections Easy to update - quick modifications
Data Analysis Difficult to analyze - manual calculations Easy to analyze - automatic calculations
Backup Difficult - must photocopy everything Easy - simple file copying
Manpower More manpower needed Less manpower needed

📚 Chapter Summary

  • Database: A collection of organized data that can be efficiently stored, retrieved, and managed.
  • Field: A column in a table (single piece of information)
  • Record: A row in a table (collection of related fields)
  • Table: A collection of records
  • Relational Database: A collection of related tables connected through keys
  • Primary Key: A unique identifier for each record; cannot be empty or duplicate
  • Composite Primary Key: A primary key made of two or more fields
  • Foreign Key: A field that links to the primary key of another table
  • Data Redundancy: Storing the same data in multiple places (should be minimized)
  • Data Consistency: Ensuring data accuracy across all tables
  • Data Types: Text, Number (Integer/Real), Currency, Date/Time, Boolean
  • Relationships: One-to-One, One-to-Many, Many-to-Many
  • DBMS Objects: Tables, Queries, Forms, Reports
  • Query: Used to retrieve and analyze specific data from tables
  • Form: User-friendly interface for data entry and viewing
  • Report: Formatted presentation of data for printing
  • Referential Integrity: Ensures relationships between tables remain consistent
  • Data Encryption: Protects data by converting it to unreadable format
  • Advantages of Electronic Databases: Efficient, accurate, space-saving, easy to analyze and share
  • Junction Table: Used to implement many-to-many relationships

🎯 Key Points to Remember for Exams:

  • Always underline primary keys in table designs
  • Choose appropriate data types for each field
  • Telephone numbers should be Text, not Number
  • Minimize data redundancy to maintain consistency
  • Foreign keys create relationships between tables
  • Many-to-many relationships require a junction table
  • Queries can filter, sort, and calculate data
  • Forms are for data entry, Reports are for presentation