DATABASE NOTES
1. Introduction to Databases
A database is an organized collection of related data stored electronically so that it can be easily accessed,
managed, and updated.
Examples of databases:
• School records database
• Hospital patient database
• Banking database
• Library database
Importance of Databases
• Stores large amounts of information
• Makes data retrieval easy
• Reduces duplication of data
• Improves data security
• Makes updating information faster
2. Building a Database
Building a database involves creating a new database file and designing tables to store data.
Steps in Creating a New Database
1. Open the database software (e.g., Microsoft Access)
2. Click New Database
3. Enter the database name
4. Choose storage location
5. Click Create
3. Database Terms
a) Table
A table is an object used to store data in rows and columns.
Example:
Student ID Name Class
001 John 10A
b) Field
A field is a column in a table that stores one type of information.
Examples:
• Name
• Age
• Address
c) Record
A record is a row in a table containing complete information about one item or person.
Example:
| 001 | John | 10A |
This whole row is one record.
d) Auto Number Field
An Auto Number field automatically generates numbers for each new record.
Example:
1, 2, 3, 4…
Used for:
• Student IDs
• Customer numbers
e) Primary Key
A primary key is a field that uniquely identifies each record in a table.
Characteristics:
• Cannot contain duplicates
• Cannot be empty
Examples:
• NRC Number
• Student ID
• Employee ID
Purpose:
• Prevents duplicate records
• Helps create relationships between tables
f) Reports
Reports are formatted outputs of database information used for printing or viewing summaries.
Examples:
• Student report forms
• Sales reports
• Employee reports
4. Data Entry and Editing
Data Entry
Data entry is the process of entering information into database tables.
Example:
Typing student names into a student table.
Editing Data
Editing means changing existing information in a database.
Examples:
• Correcting spelling mistakes
• Updating phone numbers
5. Relationships in Databases
A relationship links tables together using common fields.
Example:
• Student Table
• Results Table
Both may share:
• Student ID
Types of Relationships
a) One-to-One Relationship
One record in Table A relates to one record in Table B.
Example:
One person → One passport
b) One-to-Many Relationship
One record in Table A relates to many records in Table B.
Example:
One teacher → Many students
c) Many-to-Many Relationship
Many records in one table relate to many records in another table.
Example:
Many students → Many subjects
6. Making Relationships
Steps:
1. Create tables
2. Set primary keys
3. Open Relationship View
4. Add tables
5. Drag the primary key from one table to matching field in another table
6. Click Create
7. Form Wizard
A Form Wizard helps users create forms automatically for entering and viewing data.
Importance of Forms
• Easier data entry
• User friendly
• Faster access to records
8. Checking Relationships
Checking relationships ensures tables are correctly connected.
Importance:
• Prevents data inconsistency
• Ensures accurate data retrieval
• Maintains database integrity
9. Adding and Deleting Fields
Adding Fields
Adding a new column to a table.
Examples:
• Adding “Phone Number”
• Adding “Email Address”
Steps:
1. Open table in Design View
2. Insert new field
3. Save changes
Deleting Fields
Removing unnecessary fields from a table.
Steps:
1. Select field
2. Click Delete
3. Save changes
Note:
Deleting a field permanently removes its data.
10. Searching for Records
Searching means locating specific information in a database.
Examples:
• Finding a student by name
• Finding an employee by ID
Methods:
• Search box
• Find command
11. Sorting Records
Sorting arranges records in order.
Types:
Ascending Order
• A to Z
• 1 to 9
Descending Order
• Z to A
• 9 to 1
Importance:
• Makes information easier to read
• Speeds up searching
12. Filtering Records
Filtering displays only records meeting specific conditions.
Example:
Show only students in Grade 12.
Importance:
• Reduces unnecessary data
• Helps focus on specific information
13. Copying and Moving Records
Copying Records
Creates duplicates of records.
Moving Records
Transfers records from one place to another.
14. Queries
A query is a request used to retrieve specific information from a database.
Examples:
• Students who scored above 50%
• Employees in Lusaka
Creating Queries
Steps:
1. Open Query Design
2. Add tables
3. Select fields
4. Enter criteria
5. Run query
Running Queries
Running a query displays the requested information.
Benefits:
• Fast retrieval of data
• Helps in analysis
• Produces reports
15. Database Forms
A form is a user-friendly screen used for entering and viewing data.
Examples:
• Student registration form
• Employee details form
16. Designing and Redesigning Database Forms
Designing Forms
Creating forms to suit user needs.
Features:
• Text boxes
• Buttons
• Labels
• Images
Redesigning Forms
Improving existing forms by:
• Changing layout
• Adding controls
• Improving appearance
Importance:
• Makes forms easier to use
• Improves efficiency
• Enhances appearance
SUMMARY OF IMPORTANT TERMS
Term Meaning
Database Organized collection of data
Table Stores data in rows and columns
Field A column in a table
Record A row in a table
Primary Key Unique identifier
Query Request for information
Form Interface for data entry
Report Formatted output of data
Relationship Link between tables