Unit 1 of 1 · B.Sc IT Sem 4

Unit 1: MS Access database practice

Software Lab-VII (Database Management Systems) notes · PTU syllabus (BSIT406/BSBC406)

3 min read10 topics10 exam questions
On this page
  1. Unit summary
  2. MS Access: features and elements
  3. Window components
  4. Creating and saving a database and tables
  5. DDL commands through SQL view
  6. DML commands through SQL view
  7. Creating views (saved queries)
  8. Using forms
  9. Using reports
  10. Introduction to Crystal Reports
  11. Practical list
  12. Key terms
  13. Quick revision
  14. 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
ComparisonSQL command types
Purpose
Examples

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

1

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.
Key termsFeatures of MS Access
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
FrameworkMain database objects
  • 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

2

Topic 2

Window components

Key termsAccess 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
3

Topic 3

Creating and saving a database and tables

ProcessCreate a database and table
  1. 1

    Open Access and choose Blank database

  2. 2

    Name it College.accdb and choose a folder; click Create

  3. 3

    Switch Table1 to Design view and save as Student

  4. 4

    Enter field names, data types and descriptions

  5. 5

    Set the primary key (key icon)

  6. 6

    Set field properties: size, format, validation rule, required

  7. 7

    Save and switch to Datasheet view to enter records

FieldData typeProperties
RollNoNumber (Long Integer)Primary key
NameShort TextField size 50, Required: Yes
DOBDate/TimeFormat: Short Date
CourseShort TextLookup list: BCA; B.Sc IT; BBA
MarksNumberValidation rule: Between 0 And 100
PhoneShort TextInput mask for 10 digits
FeePaidYes/NoDefault: No
  • Relationships: Database Tools → Relationships; drag Student.RollNo to Result.RollNo; tick Enforce Referential Integrity (with cascade update and delete as required).
4

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;
5

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.

6

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.
Key termsQuery types in Access
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;
7

Topic 7

Using forms

ProcessCreate a data-entry form
  1. 1

    Select the Student table

  2. 2

    Create → Form (or Form Wizard)

  3. 3

    Arrange controls in Layout view

  4. 4

    In Design view add a title, logo and command buttons (Add, Save, Delete, Close)

  5. 5

    Set properties: tab order, default values, combo box for Course

  6. 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).
8

Topic 8

Using reports

ProcessCreate a grouped report
  1. 1

    Create → Report Wizard

  2. 2

    Choose qryDistinction fields

  3. 3

    Group by Course

  4. 4

    Sort by Marks descending; Summary Options → Avg

  5. 5

    Choose layout and orientation

  6. 6

    Edit in Design view: report header, page header, group header, detail, footers

  7. 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).
9

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.
ProcessFirst report in Crystal Reports
  1. 1

    New → Standard Report Wizard

  2. 2

    Data: connect to College.accdb (Access/Excel DAO or ODBC) and select tables

  3. 3

    Link tables on RollNo and CourseID

  4. 4

    Fields: choose Name, Title, Marks

  5. 5

    Grouping: Course; Summaries: Sum and Average of Marks

  6. 6

    Record selection: Marks >= 40

  7. 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.
10

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

  1. Q1.Name the four main objects of an Access database.
  2. Q2.What is the navigation pane?
  3. Q3.How do you set a primary key in Access?
  4. Q4.What is a parameter query?
  5. Q5.Name the sections of an Access report.
  6. Q6.What is Crystal Reports used for?

Long-answer questions

  1. Q1.Create a database with tables and relationships in MS Access.
  2. Q2.Write DDL and DML commands in Access SQL view with examples.
  3. Q3.Design a form and a grouped report in MS Access.
  4. 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.

WhatsApp us