MS Access Tutorial - 2023 - Table

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

BE1255 – IT for Business 1

MS Access Tutorial

MS Access Tutorial

In this tutorial you are required to create a database for a simple invoicing system. You are
required to create 4 tables, data added to these tables, queries to obtain information from the
database, and reports to display information from the database.

The database contains the following tables and attributes with the stated data types and sizes:

Table Attribute Data Size Required Description


Type
TblCustomer CustomerID Number Long Y Customer
integer number
CustomerFirstName Short Text 50 Y Customer
first name
CustomerLastName Short Text 50 Y Customer
last name
CustomerAddress Short Text 50 Y Customer
address
CustomerCity Short Text 50 Y Customer
city
CustomerPostCode Short Text 4 N Customer
postcode
CustomerPhoneNumber Number Long N Customer
Integer phone
number

TblProduct ProductID Number Long Y Product


Integer number
ProductDescription ShortText 50 Y Product
description
ProductPrice Currency Y Product price

TblOrder OrderID Auto Order


Number number
CustomerID Number Long Y Customer
Integer number
OrderDate Data/Time Y Order date

TblOrderLine LineID Auto Order line


Number number
OrderID Number Long Y Order
Integer number
ProductID Number Long Y Product
Integer number
Qty Number Long Y Product
Integer quantity
LineTotal Currency Y Line total
BE1255 – IT for Business 2
MS Access Tutorial

Let’s Get Started


Open Microsoft Access and select Blank Database.

Give the database a suitable name SimpleInvoicingSystem and choose a folder to save it to
by clicking the folder icon.

Click Create

This creates the database and opens the default window.

Close this table without saving by clicking the X.


BE1255 – IT for Business 3
MS Access Tutorial

Creating Tables
Steps for creating a Table
1. Click Create →Table Design
2. Enter Field names, data types, and descriptions (optional)
3. Enter properties for fields
4. Set the primary key(s)
5. Save the table design (and name the table)

Creating the Customer Table

This opens the Design view for the table

Save and name the table TblCustomer (can save by closing the table or by using the save
button).
BE1255 – IT for Business 4
MS Access Tutorial

The first table to be created is for Customer

In the first Field Name type CustomerID, change the data type to Number, add a description,
and in the Field Properties section, change Indexed to ‘Yes (no duplicates)’ using the
dropdown arrow.

The CustomerID is going to be the Primary Key, so with the CustomerID field selected, click
the Primary Key button on the ribbon. Notice the key which now appears next to CustomerID.
BE1255 – IT for Business 5
MS Access Tutorial

Move down to the next row, and type CustomerFirstName in the field name cell, choose Text
as the data type, add a suitable description.

In the Field Properties Box, change the Field Size to ‘50’, and Required to ‘Yes’

Now add the rest of the Attributes with the properties given. (Refer to the table in Page 1)

Save and close the table Customer.


BE1255 – IT for Business 6
MS Access Tutorial

Now create tables for Product:

Product (primary key ProductID)

Now create tables for Order:

Order (primary key OrderID)

Now create tables for OrderLine:

OrderLine (primary key LineID)


BE1255 – IT for Business 7
MS Access Tutorial

Creating Relationships and Enforcing Referential Integrity


To create the relationships between the tables requires a link to be created between the
primary key in one table and the same data item in the other table.

Primary Key Foreign Key


TblCustomer CustomerID TblOrder CustomerID
TblOrder OrderID TblOrderLine OrderID
TblProduct ProductID TblOrderLine ProductID

Click on Database Tools → Relationships

Add all 4 tables in the ‘Show Table’ dialogue box

Rearrange and resize the tables so all attributes are shown


BE1255 – IT for Business 8
MS Access Tutorial

To create the relationship, click and drag the primary key attribute to the appropriate attribute
in the related table:

Click and Drag CustomerID from TblCustomer to the CustomerID in TblOrder.

This opens the Edit Relationships dialogue box.

Tick Enforce Referential Integrity. This is done by enforcing referential integrity which means
that before a value can be entered into the foreign key attribute, it must already exist in the
table containing the primary key.

Notice that the Relationship Type is One-To-Many, this means one CustomerID could relate
to many Order records.

Click Create.

Notice the link which has now been created between the TblCustomer and the TblOrder.
The 1 at the Customer table end means 1 customer record could be related to many (∞) order
records.

Add the rest of the relationships.

Close the relationship diagram, saving it when requested to.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy