0% found this document useful (0 votes)
12 views

Database- Access Lecture 2

The document provides an overview of Microsoft Access, a relational database management system, detailing its components such as tables, queries, forms, and reports. It outlines the steps for planning and designing a database, including defining its purpose, organizing fields, and establishing relationships between tables. Additionally, it emphasizes the importance of data integrity and methods for maintaining it within the database.

Uploaded by

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

Database- Access Lecture 2

The document provides an overview of Microsoft Access, a relational database management system, detailing its components such as tables, queries, forms, and reports. It outlines the steps for planning and designing a database, including defining its purpose, organizing fields, and establishing relationships between tables. Additionally, it emphasizes the importance of data integrity and methods for maintaining it within the database.

Uploaded by

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

Information and Communications

Technology
DATABASES– MICROSOFT ACCESS
DATABASES– MICROSOFT ACCESS

• Indicative content:
• Discuss considerations when planning or designing a database
• Explain MS Access Database components
• Explain Protection of Data Integrity in MS Access
• Explain different types of table relationships

04/10/2025 2
Understanding Microsoft Access

• Microsoft Access is a "relational" database application.


• Relational means we can link together sets of data, we can relate the data.
• Microsoft Access is an example of a database management system (DBMS) used
to manage a small database on a personal computer.
• Microsoft Access organizes data in a form of tables linked with cross-related fields
• A table is made up of records (rows) and fields (columns). Each field has a field
name (column heading)..

04/10/2025 3
Database Terminology
A database is made up
of one or more tables
• Field Individual fields

• Record
• Table
• Database

Individual tables in a
database

Records
 A database consists of one or more tables. Each table consists of records which contain information about a
single entity. An example of one complete record would be the name, author, isbn#, published date and publisher
of textbooks. Each set of information regarding one book is considered to be one record. The name, author
04/10/2025 isbn#, published data and publisher in the above example are the individual fields that make up one record.
4
Considerations when planning or
designing a database
• This process consists of seven steps
 Database purpose
 Review existing data
 Create list of fields
 Organize fields into tables
 Normalize Data
 Designate primary and foreign keys
 Determine table relationships

04/10/2025 5
 Define Database Purpose
 The purpose of database is to keep data systematic so that it can be easily
managed, accessed and update.
 Defines the scope of a database
 Helps guide the design
 Implies the kind of data
 Determine the probable users

04/10/2025 6
 Review Existing Data

• Relevant data to the statement of purpose


• Can be in paper or electronic
Paper
• Internal Business Forms
• Government Forms
• Invoices
Electronic
• Spreadsheets
• Word documents
• Databases (Access, MS SQL, Oracle, etc.)

04/10/2025 7
 Determine Fields
• The required fields depend on the information required by
the user
• Reports
• Summary information

04/10/2025 8
 Group Fields Into Tables
• Related fields should be grouped into the same table eg student
name ,student id into table student
• Define methods for data entry in a database
• Define a standard naming convention for objects.
• Example:
Student name object can be S_Fname and the lastname can be
S_Lname

04/10/2025 9
 Normalization

• Process of organizing and grouping data into more than one database
table so that data redundancy is avoided
• Optimizes table structure
• Refining database by reducing complex data into simple table
structures
• Optimizes database
• Eliminate redundancy
• Eliminate inconsistency dependency between tables

04/10/2025 10
Normalize Data

• Break data into smallest values possible


• Assure data is not repeated
• Break repeated data into separate tables
• Avoid empty fields as much as possible
• Consistent references in tables
(naming convention)

04/10/2025 11
De-normalization

• Definition
• Combining tables into a bigger table
• Uses
• Make queries run faster
• Keep similar data together
• Keep table structure simple

04/10/2025 12
 Designate Primary and Foreign
Keys
• Primary Key
• Field with unique values
• Values identify each record
• Used to create relationships between tables
• Can be of any data type except memo, OLE or Attachment
• Can never be blank
• Values do not change or have duplicates

04/10/2025 13
 Composite Key
• Made of the union of two unique fields
 Foreign Key
• Field that relates to primary key of another table
• Primary key acts as record index
• Helps implement relationship between tables
• Foreign key helps establish relationship with primary key

04/10/2025 14
 Determine Table Relationships
• Representation of association among data contained within tables
o Helps in matching fields of two or more tables
• One-to-one relationship
• Primary key and foreign key are unique
• One-to-many relationship
• Primary key unique with many foreign key values

04/10/2025 15
MS ACCESS DATABASE COMPONENTS
• MS Access uses “components" to help the user list and organize information, as
well as prepare specially designed reports. When you create a database, Access
offers you Tables, Queries, Forms, Reports, Macros, and Modules. Databases in
Access are composed of many components but the following are the major
components −
• Tables
• Queries
• Forms
• Reports
• Together, these components allow you to enter, store, analyze, and compile your
data. Here is a summary of the major components in an Access database

04/10/2025 16
04/10/2025 17
Table

• Table is an component that is used to define and store data. When you create a
new table, Access asks you to define fields which is also known as column
headings.
• Each field must have a unique name, and data type.
• Tables contain fields or columns that store different kinds of data, such as a name
or an address, and records or rows that collect all the information about a
particular instance of the subject, such as all the information about a customer or
employee etc.

04/10/2025 18
Query

• A component that provides a custom view of data from one or more tables.
• Queries are a way of searching for and compiling data from one or more tables.
• Running a query is like asking a detailed question of your database.
• When you build a query in Access, you are defining specific search conditions to
find exactly the data you want.
• A Query can pull from multiple Tables and allow you to limit the records (rows)
display by using criteria and showing only the fields (columns) you want. We can
define queries to Select, Update, Insert, or Delete data.

04/10/2025 19
Form
• Form is an component in a desktop database designed primarily for data input or
display or for control of application execution. You use forms to customize the
presentation of data that your application extracts from queries or tables.
• Forms are used for entering, modifying, and viewing records.
• Forms are also used to make menus and search windows that turn a simple data
collection tool into a more interactive user‐friendly application
• The reason forms are used so often is that they are an easy way to guide people
toward entering data correctly.
• When you enter information into a form in Access, the data goes exactly where
the database designer wants it to go in one or more related tables.

04/10/2025 20
Report

• Report is a component in desktop databases designed for formatting, calculating,


printing, and summarizing selected data.
• Reports are useful because they allow you to present components of your
database in an easy-to-read format
• You can view a report on your screen before you print it.
• If forms are for input purposes, then reports are for output.
• Anything you plan to print deserves a report, whether it is a list of patients and
addresses or a financial summary for a period of time
• Access offers you the ability to create a report from any table or query.

04/10/2025 21
Building a Database
• Create Database from template
1. To view the all the possible databases,
you can scroll down or you can also use the search box.
2. Let us enter project in the search box and press Enter.
You will see the database templates related to project management
3. Select the first template.
4. After selecting a template related to your requirements,
enter a name in the File name field and
you can also specify another location for your file if you want.

04/10/2025 22
6. Now, press the Create option.
Access will download that database template
and open a new blank database as shown
in the following screenshot.

04/10/2025 23
• Create Blank Database
1. Open Microsoft Access
2. Choose Blank Desktop Database

3. Click on the yellow folder at the end of the


File Name box and browse for the desktop

4. Use the file name: example Patient Appointments


5. Click Create
04/10/2025 24
CREATE TABLE
• Create the Patients Table or any other
1. Click on the Create tab and choose Table Design

2. Type the first Field Name: Pt_Med Rec #


a. Data Type: Short Text, Description: Patient's Medical Record Number

04/10/2025 25
3. Enter in the rest of the fields
4. Set the Pt_Med Rec # to be the key

5.Under the Description column,


enter the text that describes
what you field is. (This field is optional).
6. Save the Table as Patients
right click on table
and click save

The key/primary key


It is a key that can uniquely identify each record in a table
04/10/2025 26
• Different Views of tables:
1. Design view used to create fields
2. Datasheet view used to add, edit, or delete records
Design View

Datasheet View

04/10/2025 27
Entering First Record

1. Turn to the Datasheet View


2. Enter our first Med Rec #: 123‐456
3. Press tab move to the next field
a. First Name: Sam
b. Last Name: Franks
c. Phone #: 3525551234
No dashes
Birth Date: 1/1/1
If you set it as a DATE/TIME field Access will add in the "200" for
2001
04/10/2025 28
Types of data

• Every field in a table has properties and


these properties define the field's characteristics
and behavior. The most important property
for a field is its data type.
• A field's data type determines what kind of data
it can store.
MS Access supports different types of data,

04/10/2025 29
Exit the Database

1. Exit the database, Access will probably not ask you to save
a. But it did save the record, it does so automatically.
2. Open your database from the desktop
• a. If necessary, Enable Content
3. Open the table (double‐click) from the navigation pane
a. Sam is still there!

04/10/2025 30
Rearrange Fields

1. In Design View, move Pt_Birth Date above the Pt Phone #


• a. Click on the row heading, the grey box in front of the field name. Then
Click/Drag the line above the Pt_Phone #
2. Switch to the Datasheet View and Save the table
• a. Data saves itself, structural changes have to be saved manually
3. Enter the next record

04/10/2025 31
Adding Fields

1. In Design View, create Pt_Gender, Short Text field,


above Pt Birth Date
• a. Insert Rows from Design Tab, or from the right‐click menu
2. In Data View, enter "Male" (the whole word) for Sam and Jacob

04/10/2025 32
1. Enter the next record

• a. Enter Gender as just one character


• b. Enter birth date as March 3, 1983; it should change to 3/3/1983
• c. Type in the hyphens for the phone number
2. Go to the Design view and then return to the Data view
• a. Notice Jane's record moves. This is because by default Access sorts by the primary key
• field. Since Pt_Med Rec # is our key, every time the data is refreshed it will sort the data by
the primary key field.

04/10/2025 33
• Enter a New Record
1. Enter a new record
2. Close the Table
3. Open the Patient's Table
4. Close the Table

04/10/2025 34
CREATE QUERY
• Create Female Patient's Query
1. Go to the Create Tab
and choose Query Design

2. In the Show Table window, push the


Add button and then close the window

04/10/2025 35
3. Double‐clicking on the
field names
to add Pt_First Name,
Pt_Last Name, and Pt_Gender
4. Right click on query1
View Datasheet View query result

04/10/2025 36
Query Object Views

• Design View
• SQL View
• Datasheet View

04/10/2025 37
Using Query Wizard

• Select Query Wizard


• Select type of query
• Select query fields
• Request query detail
• Add title. Click Finish
• Query result shown

04/10/2025 38
04/10/2025 39
Customizing a Query

1. In the Datasheet view notice the sort order is by Med Rec #


2. In the Design view, set Query to Sort by Pt_Last Name Ascending
3. Go to the Data View, patients should read, Franks through Williams
4. In the Design View, set the Criteria line for the Pt_Gender field to be
F for female
• a. In Datasheet view, you should only have two people: Jane and Doris
5. Close and save the Query as Female Patients

04/10/2025 40
04/10/2025 41
Create Form
• Create Patients Form
1. Select Patients Table from left Navigation Pane so it becomes the default data source

2. On the Create Tab click on the Form button

3. We are in the Form's Layout view


• a. Place your mouse along the right border of the highlighted box
and resize
4. Change to the "Form" view (first button on the Home Tab)
5. Create a new patient, anyone you want
• a. Tab until you reach a new blank record, or use the
NEW button on the Home Tab
04/10/2025
• b. Make sure to leave the record, "pencils down!", move 42
6. Open the Patients TABLE, view new person
• a. From the left Navigation Pane, double‐click to open
7. Open the Patients QUERY, view new
person
• New patient has been saved, even
though the Form has not been saved
• If you did not close the table and/or query,
you may not see the person right away.
• Close the object, and when you open them
• you'll see the new person
8. Close all, Save Form as "Patients"

04/10/2025 43
Create Report

• Create Simple Report


1. Select Table from left Navigation Pane so it becomes the default data source
2. On the Create Tab click on the REPORT button

3. The report opens in Layout View, adjust the columns to fit the data
4. Right‐click in an empty space and go to the Print Preview
5. Close and Save as Patients

04/10/2025 44
04/10/2025 45
Report

04/10/2025 46
Protecting Data Integrity in MS
Access
• The term data integrity refers to the accuracy and consistency of data.
• When creating databases, attention needs to be given to data integrity and how
to maintain it.
• A good database will enforce data integrity whenever possible.

Referential Integrity
• Process to ensure data validity across two tables
• It is enforced by ensuring values in a foreign field have corresponding values in the primary
key
• Referential integrity prevents the entering of invalid data

04/10/2025 47
• Benefits of Referential Integrity
• Avoid data loss
• Avoid updating data
• Referential integrity between two table can be set if:
• Both tables are in the same database
• The matching field is a primary key in one table or has a unique index
• The related fields have the same data type

04/10/2025 48
Types of table relationships
• A relationship works by matching data in key columns usually columns
with the same name in both the tables.
• In most cases, the relationship matches the primary key from one
table, which provides a unique identifier for each row, with an entry in
the foreign key in the other table.
• There are three types of relationships between tables.
• One-to-One
• One-to-Many (or Many-to-One)
• Many-to-Many

04/10/2025 49
One-to-One
• In a one-to-one relationship, a row in table A can have no more than one
matching row in table B, and vice versa.
• one-to-one relationship is created if both the related columns are primary keys or
have unique constraints
• This is not a common relationship type, as the data stored in table B could just
have easily been stored in table A

04/10/2025 50
One-to-Many
• In this type of relationship, a row in table A can have many matching rows in table
B, but a row in table B can have only one matching row in table A.
• This is the most common relationship type.
• In the below example, the Customer table is the “many” and the City table is the
“one”.
• Each customer can only be assigned one city,. One city can be assigned to many
customers or each student can only be assigned one faculty,. One faculty can be
assigned to many students

04/10/2025 51
Many-to-Many Relationships
• In a many-to-many relationship, a row in table A can have many matching rows in
table B, and vice versa.
• A many-to-many relationship could be thought of as two one-to-many
relationships, linked by an intermediary/junction table.
• A junction table is used to link the other two tables together. It does this by
having two fields that reference the primary key of each of the other two tables.

04/10/2025 52
Assignment
1. Create table Appointment and add the records as below

2. Create a query to display Pt_Med_Rec #, Appt_Doctor, Appt_Reason


3. Create a query to display all patients supposed to have a check up
4.Create form appointment

04/10/2025 53
NEXT LESSON
• Create the Relationship Between Tables
• Define Structured Query Language
• Sort and filter records
• Write and execute SQL Statements

04/10/2025 54
Thank You.

You might also like