Database- Access Lecture 2
Database- Access Lecture 2
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
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
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
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
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
04/10/2025 25
3. Enter in the rest of the fields
4. Set the Pt_Med Rec # to be the key
Datasheet View
04/10/2025 27
Entering First Record
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
04/10/2025 31
Adding Fields
04/10/2025 32
1. Enter the next record
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
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
04/10/2025 38
04/10/2025 39
Customizing a Query
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
04/10/2025 43
Create Report
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
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.