Академический Документы
Профессиональный Документы
Культура Документы
MS Access 2016
In this lab, you will:
learn to design Databases with MS Access 2016
References:
Joyce Cox and Joan Lambert, Microsoft Access 2013 Step by Step
(Microsoft Press 2013)
This Tutorial has been adopted from Microsoft website and the book above
with modification.
Consider the following Database which gives information about clients and
property rental.
This database has four tables (Clients, Rental PropertyForRent and Owner).
Lets implement this database in MS Access 2016.
Page 1 of 8
COS10082 Applied Analytics in Business Lab 5
A default Table1 will be created (can be seen at the left side of Access) with
one attribute ID (which is created to be the unique identifier for the table
Primary key). You will notice that Table Tools are activated since we are now
working with tables.
On the Table Tool -> Fields, go to View and click on Design view, you will be
asked to rename Table1, rename it to Client
The fields of the table will be shown, so, rename ID to ClientNo and change
the data type to the most appropriate data type to store the data given.
Add the second field of the table Client and select Short text as the data
type.
Page 2 of 8
COS10082 Applied Analytics in Business Lab 5
Right-click on the key next to the left of the ClientNo field and make sure
Primary key is selected.
Go back to Data Sheet View, and insert the data given in the Client Table.
Now, lets create the Rental Table and insert the data
Now, lets Repeat the above steps to create PropertyForRent and Owner
tables, and insert their data.
Page 3 of 8
COS10082 Applied Analytics in Business Lab 5
Close all tables (using the close icon at the right side of each table)
On the Database Tools tab, in the Relationships group, click the Relationships
button to open the Show Table dialog box.
Add all tables (select a table name and click add) then click on close
We have four tables, and their fields are listed. By looking at Client and Rental,
we can notice that both have one common field (ClientNo) which indicates
that these two table have a direct relationship. The same thing goes for Owner
and PropertyForRent as well as PropertyForRent and Rental.
On the Client Table, click and hold on the ClientNo and drag it to the
ClientNo field on Rental table.
The Edit Relationships window will appear as follows:
Select the Enforce Referential Integrity check box, and then click Create
A one-to-many relationship will be created between the two tables. (you can
re-arrange the tables by click and drag the table to another location.
Page 4 of 8
COS10082 Applied Analytics in Business Lab 5
Now, we will learn on how to retrieve information from either one or multiple
tables.
Using Query Wizard
Lets design a query that will display the Client Name and the Address of the
Property they have rented.
- The two columns, are available in the Client table(Client Name) and
ProperyForRent(PAddress). But both have a relationship with the Rental
table.
On Create tab -> Queries Group, click on Query Wizard
Select Simple Query Wizard, then click OK
The following Simple Query Wizard window will appear.
Select the Table from Tables/Queries drop down menu and then select the
field then click on to transform the column to Selected Fields.
Page 5 of 8
COS10082 Applied Analytics in Business Lab 5
Click on Next
On the following dialogue, tick on detail, then click Next
Give the Query a title. Then click Finish.
You should get the following:
Page 6 of 8
COS10082 Applied Analytics in Business Lab 5
Lets design a query that displays the Client Name, Property No, Rental start
date, rental end date and the owner name.
- This query involves Client Table, Rental Table, and Owner Table.
On Create tab -> Queries Group, click on Query Design
On the Show table window, select the all tables
You should see this
Now, lets select the fields that we are interested with using the Field drop down
menu that appears at the bottom of the above picture.
Select, CName from Client, PropertyNo from Rental, RentStart from Rental,
RentFinish from Rental and OName from Owner.
To see the result, click on Run button.
You should get this
Page 7 of 8
COS10082 Applied Analytics in Business Lab 5
Lets only display the same columns but for rents that start after 15/7/2013
To do this,
Click on Run
You can select / retrieve information based on multiple conditions and you
may use AND or OR. If you want to use AND for multiple conditions use them in
the same row; if OR, then write the condition on the or: row.
Your Turn
Develop the following Library Database in Access. Add some data
Page 8 of 8