Grade 8_Computer_Database
• A database is an organized collection of data that is stored and managed so it can be
easily accessed, updated, and retrieved when needed.
• Key Points:
o A database stores data (facts, numbers, text, images, etc.) systematically.
o It allows insertion, deletion, updating, and searching of data efficiently.
o It is managed using a Database Management System (DBMS)
Why Database is important
1. Organized Data Storage
• Keeps data in tables or collections instead of scattered files.
• Example: A school can keep students’ names, grades, and fees in one place.
2. Quick Access & Searching
• You can easily find the information you need.
• Example: Searching “all students of Class 10” takes seconds in a database.
3. Data Security & Privacy
• Databases protect data with passwords and access control.
• Example: Only the bank manager can see loan details, not everyone.
4. Accuracy & Consistency
• Reduces mistakes and keeps data the same across the system.
• Example: If a student’s address changes, it updates everywhere.
5. Supports Large Amounts of Data
• Can handle millions of records without confusion.
• Example: Amazon stores details of millions of products.
Table
A table is a collection of rows and columns that represent related data.
• Columns (Fields/Attributes): Define the type of data (like Name, Age, Roll_No).
• Rows (Records/Tuples): Contain the actual data values.
Datatypes in MS Access
1. Short Text
• Stores text, numbers (not used for calculations), or combinations.
• Up to 255 characters.
• Example: Names, Phone numbers, Roll No.
2. Long Text (Memo)
• Stores long paragraphs or large text.
• Up to 65,536 characters.
• Example: Address, Notes, Descriptions.
3. Number
• Stores numeric values for calculations.
• Types: Byte, Integer, Long Integer, Single, Double, Decimal.
• Example: Age, Marks, Salary.
4. Date/Time
• Stores date and time values.
• Example: 14-Aug-2025, 10:30 AM.
5. Currency
• Stores monetary values (with 4 decimal places).
• Example: ₹5000.50 or $120.75.
6. AutoNumber
• Automatically generates a unique number for each record.
• Often used as Primary Key.
• Example: 1, 2, 3, … (auto-generated IDs).
7. Yes/No (Boolean)
• Stores True/False, Yes/No, or On/Off values.
• Example: Fees Paid (Yes/No), Attendance (Present/Absent).
Primary Key
A Primary Key is a field (or combination of fields) in a table that uniquely identifies each
record.
• It cannot be empty (NULL).
• It cannot have duplicate values.
Rules of Primary Key:
1. Must be unique (no two records have the same key).
2. Cannot be NULL (blank).
3. A table can have only one primary key, but it may consist of multiple columns
(called Composite Primary Key).
Why is a Primary Key Important?
1. Uniqueness of Records
o Ensures every record in the table is unique.
o Example: Two students can’t have the same Roll_No.
2. Prevents Duplicate Data
o Avoids repetition of the same entry.
o Example: You can’t add another student with Roll_No = 101.
3. No Missing Values
o Primary Key cannot be NULL, so every record is identifiable.
o Example: Each employee must have an Employee_ID.
4. Easy Identification
o Makes it simple to search and update records.
o Example: Instead of searching by name (which may be repeated), you can use
Roll_No.
How to Create a Table in MS Access
You can create a table in MS Access in two ways:
1. Datasheet View
2. Design View
Creating a Table in Datasheet View (Easiest Method)
1. Open MS Access
2. Choose Blank Database and create a new file.
3. Access automatically creates a table named Table1 in Datasheet View.
4. Click on the column header Click to Add.
5. Select the data type (Short Text, Number, Date/Time, etc.).
6. Type the field name (for example: Name, Age, Class).
7. Enter your data in the rows.
8. Save the table using Ctrl + S → Give a name (e.g., "Student").
2. Creating a Table in Design View (More Structured Method)
This method gives more control over fields and data types.
1. Go to the Create tab on the Ribbon.
2. Click Table Design.
3. A new table opens in Design View.
4. Enter:
o Field Name (e.g., StudentID, Name, Marks)
o Data Type (Short Text, Number, AutoNumber, etc.)
o Description (optional notes)
5. Choose a Primary Key:
o Select the field → Click Primary Key on the toolbar.
6. After entering fields, save the table using Ctrl + S.
7. Close Design View → switch to Datasheet View to enter data.
Different Views of a Table in MS Access
MS Access mainly provides two important views to work with a table:
1. Datasheet View
What it is:
• It shows the table in a grid format, like an Excel sheet.
• You can enter, edit, and delete data directly.
What you can do:
• Add records (rows)
• Add fields (columns)
• Sort and filter data
• View data quickly
2. Design View
What it is:
• Used to define the structure of the table.
• You cannot enter data here; you only design the fields.
What you can do:
• Add field names
• Set data types (Text, Number, Date, etc.)
• Add descriptions
• Set Primary Key
• Apply validation rules
• Set field size
Form in MS Access
A Form in MS Access is an object used to enter, display, and edit data in a user-friendly way.
Instead of entering data directly into a table (which can be confusing), forms give a clean and
easy interface—like a mini application screen.
Why Forms Are Used
✔ To enter data easily
✔ To avoid mistakes while typing
✔ To show one record at a time
✔ To make the database look professional
✔ To control how users interact with data
Features of a Form
• Shows information from one or more tables
• Provides buttons (Save, Next, Previous, Search)
• Can have text boxes, labels, images, combo boxes, etc.
• Helps create a secure and controlled data-entry environment
How to Create a Form in MS Access
1. Using Form Button (Quick Form)
1. Select the table for which you want the form.
2. Go to the Create tab.
3. Click Form.
4. Access automatically creates a form displaying all fields.
2. Using Form Wizard
1. Go to Create → Form Wizard.
2. Select the table or query.
3. Choose fields you want in the form.
4. Choose layout (Columnar, Tabular, Datasheet, Justified).
5. Finish → Form is created.
3. Using Design View
1. Go to Create → Form Design.
2. Add controls manually:
o Text box
o Label
o Button
o Combo box
3. Link each control to a field in the table.
4. Save the form.
Relationship in MS Access
A relationship in MS Access is a connection between two tables based on a common field.
It helps databases work like linked information instead of isolated tables.
Example:
• Student Table has ClassID
• Class Table has ClassID
Linking these creates a relationship.
Why Relationships Are Important
✔ Avoids repeating the same data (removes duplication)
✔ Makes the database organized
✔ Allows data to be connected across tables
✔ Helps maintain data accuracy (referential integrity)
✔ Enables queries, forms, and reports to combine data easily
Types of Relationships in MS Access
1. One-to-One (1:1)
• One record in Table A matches one record in Table B.
• Example: One student → one library card.
2. One-to-Many (1:M)
(Most common)
• One record in Table A is related to many records in Table B.
• Example:
o One class → many students
o One teacher → many subjects
3. Many-to-Many (M:N)
• Many records in Table A are related to many in Table B.
• Access uses a third table (junction table) to create this.
Example:
• Students take many courses
• Courses have many students
Key Terms
1. Primary Key: A field that uniquely identifies each record in a table.
2. Foreign Key: A primary key from another table used to create a link.
3. Referential Integrity: Rules that keep relationships valid and prevent wrong data.
How to Create a Relationship in MS Access
1. Go to Database Tools tab.
2. Click Relationships.
3. Add tables you want to connect.
4. Drag the primary key from one table to the matching field in the other table.
5. Choose the relationship type.
6. Click Enforce Referential Integrity (optional but recommended).
7. Click Create.
Queries in MS Access
A Query in MS Access is a tool used to retrieve, filter, sort, calculate, or update data from one
or more tables.
It helps you ask questions from the database and get only the information you need.
Why Queries Are Used
✔ To filter specific records
✔ To sort data
✔ To select only required fields
✔ To perform calculations
✔ To join multiple tables
✔ To update or delete multiple records at once
How to Create a Query in MS Access
Using Query Design
1. Go to Create tab
2. Click Query Design
3. Add table(s)
4. Select the fields you want
5. Add criteria (conditions) in the grid
6. Click Run (red exclamation mark)
Example of a Simple Query
Question: Show all students whose marks are greater than 75.
Criteria: Marks > 75
Benefits of Queries
✔ Saves time
✔ Faster searching
✔ Helps in decision-making
✔ Extracts meaningful information
✔ Useful for reports and forms
Reports in MS Access
A Report in MS Access is a tool used to present data in a well-organized, printed, or
shareable format.
It is mainly used for summaries, analysis, and printing output.
Reports help you convert raw data into professional-looking documents, such as:
• Marksheet
• Invoice
• Attendance report
• Sales summary
Why Reports Are Used
✔ To present data neatly
✔ To print information in a formatted style
✔ To create summaries and totals
✔ To group related records
✔ To make official documents
✔ To show important insights
Parts of a Report
A report can have several sections:
1. Report Header
o Appears at the top of the report
o Contains title, logo, date, etc.
2. Page Header
o Appears at the top of every page
o Contains column headings
3. Detail Section
oMain part of the report
oDisplays the actual data from the table/query
4. Page Footer
o Appears at the bottom of each page
o Page numbers, date/time
5. Report Footer
o Appears at the end of the report
o Totals, summaries, or conclusions
How to Create a Report in MS Access
1. Using Report Tool (Quick Report)
1. Select the table or query.
2. Go to Create tab.
3. Click Report.
4. Access instantly creates a report.
2. Using Report Wizard
1. Go to Create → Report Wizard
2. Select the table/query
3. Choose the fields to include
4. Choose grouping and sorting
5. Select layout and style
6. Finish → The report is created
Different Views of a Report
View Purpose
Report View View data but cannot make layout changes
Print Preview Check how the report will look when printed
Layout View Edit layout while viewing data
Design View Complete control to design the report structure