Unit 1: MS Access database practice
Software Lab-VII (Database Management Systems) notes · PTU syllabus (BSIT406/BSBC406)
On this page
- Unit summary
- MS Access: features and elements
- Window components
- Creating and saving a database and tables
- DDL commands through SQL view
- DML commands through SQL view
- Creating views (saved queries)
- Using forms
- Using reports
- Introduction to Crystal Reports
- Practical list
- Key terms
- Quick revision
- Important questions
Unit summary
This lab builds practical database skills in Microsoft Access: its features, elements and window components, creating and saving databases and tables, running DDL and DML commands through SQL view, creating views (saved queries), designing forms and reports, and introductory practicals on Crystal Reports.
After this unit you can
- Identify MS Access features, objects and window components
- Create and save databases and tables with keys and relationships
- Run DDL and DML commands in SQL view and create saved queries
- Design forms and reports, and produce a report in Crystal Reports
PTU syllabus topics
- MS Access features
- elements and window components
- creating and saving databases and tables
- running DDL and DML commands via SQL
- creating views
- using forms and reports
- introductory practicals on Crystal Reports
DDL
Define structure
CREATE, ALTER, DROP
DML
Change data
INSERT, UPDATE, DELETE
DQL
Query data
SELECT
DCL
Control access
GRANT, REVOKE
TCL
Manage transactions
COMMIT, ROLLBACK
Topic 1
MS Access: features and elements
- Microsoft Access is a desktop relational DBMS in Microsoft 365 that combines the Jet/ACE database engine with a graphical interface; a database is saved as a single .accdb file.
- Relational tables
- With primary keys, relationships and referential integrity
- Query design and SQL view
- Build queries visually or write SQL
- Forms
- Friendly data entry screens
- Reports
- Formatted, grouped printouts
- Macros and VBA
- Automate tasks
- Import and export
- Excel, CSV, ODBC, SharePoint
- Wizards
- Table, query, form and report wizards
Tables
Store data in rows and columns
Queries
Retrieve, calculate and change data
Forms
Enter and view data one record at a time
Reports
Present data for printing
Topic 2
Window components
- Title bar and Quick Access Toolbar
- File name; Save, Undo
- Ribbon
- Tabs: File (Backstage), Home, Create, External Data, Database Tools
- Navigation pane
- Lists tables, queries, forms and reports
- Document window (tabs)
- Opened objects in Datasheet or Design view
- Record navigation bar
- First, previous, next, last, new record, search
- Status bar
- Current view and view-switching buttons
Topic 3
Creating and saving a database and tables
- 1
Open Access and choose Blank database
- 2
Name it College.accdb and choose a folder; click Create
- 3
Switch Table1 to Design view and save as Student
- 4
Enter field names, data types and descriptions
- 5
Set the primary key (key icon)
- 6
Set field properties: size, format, validation rule, required
- 7
Save and switch to Datasheet view to enter records
| Field | Data type | Properties |
|---|---|---|
| RollNo | Number (Long Integer) | Primary key |
| Name | Short Text | Field size 50, Required: Yes |
| DOB | Date/Time | Format: Short Date |
| Course | Short Text | Lookup list: BCA; B.Sc IT; BBA |
| Marks | Number | Validation rule: Between 0 And 100 |
| Phone | Short Text | Input mask for 10 digits |
| FeePaid | Yes/No | Default: No |
- Relationships: Database Tools → Relationships; drag Student.RollNo to Result.RollNo; tick Enforce Referential Integrity (with cascade update and delete as required).
Topic 4
DDL commands through SQL view
- Create → Query Design → close the table list → SQL view, type the command, then Run.
sqlCREATE TABLE Course (
CourseID TEXT(10) PRIMARY KEY,
Title TEXT(50) NOT NULL,
Fee CURRENCY
);
CREATE TABLE Result (
RollNo LONG,
CourseID TEXT(10),
Marks INTEGER,
CONSTRAINT pk_result PRIMARY KEY (RollNo, CourseID),
CONSTRAINT fk_course FOREIGN KEY (CourseID) REFERENCES Course (CourseID)
);
ALTER TABLE Course ADD COLUMN Duration INTEGER;
ALTER TABLE Course DROP COLUMN Duration;
CREATE INDEX idx_title ON Course (Title);
DROP TABLE Result;Topic 5
DML commands through SQL view
sqlINSERT INTO Course (CourseID, Title, Fee) VALUES ('BSCIT', 'B.Sc IT', 42000);
INSERT INTO Student (RollNo, Name, Course, Marks) VALUES (101, 'Aman', 'B.Sc IT', 78);
UPDATE Student SET Marks = Marks + 5 WHERE Course = 'B.Sc IT' AND Marks < 40;
DELETE FROM Student WHERE RollNo = 105;
SELECT Name, Marks FROM Student WHERE Marks >= 60 ORDER BY Marks DESC;
SELECT Course, COUNT(*) AS Students, AVG(Marks) AS AvgMarks
FROM Student GROUP BY Course HAVING AVG(Marks) > 50;
SELECT * FROM Student WHERE Name LIKE 'A*'; -- Access wildcard is *
SELECT * FROM Student WHERE DOB BETWEEN #01/01/2006# AND #12/31/2006#; -- dates in #Exam tip
Access SQL differs slightly from standard SQL: * and ? are wildcards in LIKE, dates are enclosed in # signs, and TOP n is used instead of LIMIT.
Topic 6
Creating views (saved queries)
- Access has no CREATE VIEW in normal use; a saved select query acts as a view and can be used like a table in forms, reports and other queries.
- Select query
- Retrieve rows — the usual view
- Parameter query
- Asks for a value at run time: WHERE Course = [Enter course]
- Crosstab query
- Summarises like a pivot table
- Make-table query
- Creates a new table from results
- Append, update and delete queries
- Action queries that change data
sql-- saved as qryDistinction
SELECT s.RollNo, s.Name, c.Title, r.Marks
FROM (Student AS s INNER JOIN Result AS r ON s.RollNo = r.RollNo)
INNER JOIN Course AS c ON r.CourseID = c.CourseID
WHERE r.Marks >= 75;Topic 7
Using forms
- 1
Select the Student table
- 2
Create → Form (or Form Wizard)
- 3
Arrange controls in Layout view
- 4
In Design view add a title, logo and command buttons (Add, Save, Delete, Close)
- 5
Set properties: tab order, default values, combo box for Course
- 6
Save as frmStudent and test in Form view
- Form types: single record, multiple items, split form, and main form with a subform (student with results).
Topic 8
Using reports
- 1
Create → Report Wizard
- 2
Choose qryDistinction fields
- 3
Group by Course
- 4
Sort by Marks descending; Summary Options → Avg
- 5
Choose layout and orientation
- 6
Edit in Design view: report header, page header, group header, detail, footers
- 7
Print preview and export to PDF
- Report sections: report header, page header, group header, detail, group footer (totals), page footer (page numbers), report footer (grand totals).
Topic 9
Introduction to Crystal Reports
- Crystal Reports (SAP) is a business reporting tool that connects to databases (Access, SQL Server, Oracle, MySQL through ODBC) and produces formatted, interactive reports; it is also embedded in many .NET and ERP applications.
- 1
New → Standard Report Wizard
- 2
Data: connect to College.accdb (Access/Excel DAO or ODBC) and select tables
- 3
Link tables on RollNo and CourseID
- 4
Fields: choose Name, Title, Marks
- 5
Grouping: Course; Summaries: Sum and Average of Marks
- 6
Record selection: Marks >= 40
- 7
Template, preview and export (PDF, Excel)
- Key elements: sections (report header, page header, group header, details, footers), formula fields, parameter fields, running totals, charts and cross-tabs.
Topic 10
Practical list
- Create the College database with Student, Course and Result tables, keys and relationships.
- Apply validation rules, input masks, lookup fields and default values.
- Run CREATE, ALTER and DROP commands in SQL view.
- Insert, update and delete records using SQL; write select queries with conditions, sorting and grouping.
- Create parameter, crosstab and join queries and save them as views.
- Design a student data-entry form with command buttons and a subform.
- Design a grouped report of results with averages and page numbers.
- Create a Crystal Report of course-wise results with a chart.
Key terms
- .accdb
- File format of an Access database
- Navigation pane
- Panel listing all database objects
- Saved query
- Stored query acting as a view
- Referential integrity
- Rule that related records must exist
- Crystal Reports
- Business reporting tool for database reports
Quick revision
- Objects: tables, queries, forms, reports, macros, modules.
- Design view vs Datasheet view; data types and field properties.
- DDL and DML in SQL view; Access wildcards and dates.
- Select, parameter, crosstab and action queries.
- Forms, reports and their sections; Crystal Reports wizard.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Name the four main objects of an Access database.
- Q2.What is the navigation pane?
- Q3.How do you set a primary key in Access?
- Q4.What is a parameter query?
- Q5.Name the sections of an Access report.
- Q6.What is Crystal Reports used for?
Long-answer questions
- Q1.Create a database with tables and relationships in MS Access.
- Q2.Write DDL and DML commands in Access SQL view with examples.
- Q3.Design a form and a grouped report in MS Access.
- Q4.Explain the steps to create a report in Crystal Reports.
Stuck on this unit?
Message SBS on WhatsApp for help with Software Lab-VII (Database Management Systems), or to ask about studying B.Sc IT at Synetic.
