0% found this document useful (0 votes)
26 views2 pages

Database_ practical guide by Mirza Bashir

More practical practices for database students bzu Multan

Uploaded by

nshizuka663
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Database_ practical guide by Mirza Bashir

More practical practices for database students bzu Multan

Uploaded by

nshizuka663
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Comprehensive Guide to Database Systems Using MS Access and SQL

Introduction
This document is a step-by-step practical guide to implementing database systems based on
the provided course outline. It covers theoretical concepts, practical tasks, and detailed
instructions for using Microsoft Access and SQL. The guide ensures no topic is left out.

1. Database Structure Design


This section covers how to design the structure of a database based on the given subjects.

Tables and Attributes:


The following tables are designed for a School Management System:
1. Students: StudentID (PK), Name, Age, Gender, Address
2. Courses: CourseID (PK), CourseName, Credits, DeptID
3. Teachers: TeacherID (PK), Name, Qualification, DeptID
4. Departments: DeptID (PK), DeptName, DeptHead
5. Enrollments: EnrollmentID (PK), StudentID (FK), CourseID (FK), Marks, Grade

2. Creating Tables and Relationships in MS Access


Step-by-step instructions for creating tables and relationships in Microsoft Access:
1. Open MS Access and create a blank database.
2. Go to 'Create' tab and click on 'Table Design'.
3. Define fields with their respective data types (e.g., StudentID: AutoNumber, Name: Text).
4. Set the primary key by right-clicking on the field and selecting 'Set as Primary Key'.
5. Save the table with an appropriate name (e.g., Students, Courses).
6. To establish relationships, go to 'Database Tools' → 'Relationships'.
7. Drag and drop fields to create relationships between tables and enforce referential
integrity.

3. Frontend Design Using Forms


Forms are used to create a user-friendly interface for data input and interaction. The
following steps explain how to design forms in MS Access:
1. Go to 'Create' tab and click on 'Form Wizard'.
2. Select the table (e.g., Students) and choose fields to include.
3. Choose the layout (e.g., Columnar, Tabular) and click 'Finish'.
4. Customize the form in Design View by adjusting field sizes and adding buttons.

4. Writing Queries in SQL


SQL queries are used to retrieve and manipulate data. Examples include:
Basic Queries:
1. Retrieve all students:
SELECT * FROM Students;

2. Retrieve student names and ages where age > 18:


SELECT Name, Age FROM Students WHERE Age > 18;

Joins and Aggregations:


1. Join Students and Enrollments:
SELECT Students.Name, Courses.CourseName
FROM Enrollments
INNER JOIN Students ON Enrollments.StudentID = Students.StudentID
INNER JOIN Courses ON Enrollments.CourseID = Courses.CourseID;

2. Calculate total students in each course:


SELECT CourseID, COUNT(StudentID) AS TotalStudents
FROM Enrollments
GROUP BY CourseID;

5. Reports and Analysis


Reports are used to present data in a structured format. Steps to create reports in MS
Access:
1. Go to 'Create' tab and click on 'Report Wizard'.
2. Select a table or query as the data source.
3. Choose fields to include in the report and click 'Finish'.
4. Customize the report layout in Design View.

6. Backend Integration and VBA


Forms can be linked to backend tables or queries for data interaction. VBA can be used for
advanced functionalities. Example VBA code for inserting data:
Private Sub SaveButton_Click()
DoCmd.RunSQL "INSERT INTO Students (Name, Age) VALUES ('Ali', 20)"
End Sub

You might also like