You are on page 1of 41

Office 2010

Database Management Systems


A database is simply a collection of related data or information. For example:
 Your address book is a database
 The name is related to a particular address, phone number.
 You can access an address by looking up a name via - the alphabetic
tab at the side of the address book.
 The telephone directory is a database
 Related information that can be readily accessed.
 Ticketmaster, a library’s system, your university's student records system are
all databases.

A database is also an ‘electronic cabinet’ complete with ‘folders’ and ‘drawers’ in


which data is stored. A database management system (DBMS) is a software program
that lets you create and manipulate data in the database. MS Access is one example
of a DBMS.

Case Study: Hammer Wines Pty Ltd


As an integral component of their
promotional strategy, Hammer Wines Pty
Ltd has decided to increase brand
awareness of their primary beer products at
point of sale. They will encourage their
business customers to install a beer tap(s).
A beer tap refers to beer dispensed from a
large pressurised canister (known as a keg)
into a glass for consumption by the patron.
They are most often found in bars and
hotels in Australia and are common in beer
drinking countries around the world.

From the customer’s side of the bar, the


customer can clearly see the colourful logo
designating the brand of beer available from
each tap, and the barman has access to the
dispenser from his side of the bar. Beer is
then sold by the glass in various sizes e.g.,
285ml-600ml, with each size glass differing
in cost.
Figure 1 – Beer from a tap

Access Workshop 1 Page 1


Activity 1
Office 2010

Figure 2 – Quad Beer taps

A beer tap will enable their business customers to achieve higher economies of scale
as they will be buying beer in bulk (a keg) rather than in bottles. There will be fewer
breakages in storing crates of beer with our business customers experiencing
increased profitability as a result.

Activity 1
Problem/Opportunity
To encourage customers to participate in the roll out of taps across the various
venues, Hammer Wines Pty Ltd has approached its beer suppliers and together they
will subsidise the purchase cost of taps into the respective venues. The customer will
only pay an installation fee. Hammer Wines Pty Ltd will need to keep a database of
taps installed and their maintenance.

Maintenance
Beer Taps are available as a single tap unit, a double tap unit (2 taps) or a quad tap
unit (4 taps). Beer taps will need to be maintained (checked and serviced) on a
regular basis, typically every 4 months. Customers can choose to enter into:
 A 12 month fixed price maintenance contract.
 A variable maintenance contract where customers pay per
service callout.
If customers have more than 5 different venues, they are able to
negotiate a lower fixed price maintenance contract.

All data provided in this case study is on a ‘cost plus’ basis and Hammer Wines Pty
Ltd will include a markup of 100% in all cases. For example:
Beers of the World has one venue, they have decided on a
variable maintenance contract the cost price of which is $75,
so the customer will be charged $150.
The exception to this is the purchase cost of the tap which has been subsidised by
the supplier. For example:

Access Workshop 1 Page 2


Activity 1
Office 2010

If the cost to Hammer Wines Pty Ltd for a Quad tap unit is
$12,000, we will not be charging the customer this fee.
This fee is subsidised by Hammer Wines Pty Ltd and its
beer suppliers.
Hammer Wines Pty Ltd hope to recoup this initial outlay via increases in sales of kegs
to customers, and over time an increase in sales of bottled beer is highly likely. The
customer will be charged for installation, plus either a fixed price or negotiated
maintenance contract, whichever is agreed to by the customer.

At this stage, Hammer Wines Pty Ltd requires:


1. A customer contact list including names of associated venues for each
customer.
2. A total cost to Hammer Wines Pty Ltd of providing taps.
3. An analysis of maintenance problems on a half-yearly basis.
4. A maintenance call out schedule for each customer.

Design & Build a Simple Database


We will design and build a simple database for Hammer Wines Pty Ltd to maintain all
the information. In a relational database, this can consist of many related (linked)
tables.

In the Hammer Wines Pty Ltd case study, you will be keeping records on
their customers,
the venues (a customer can own a number of venues),
the type of taps available,
the taps installed in the venues,
the maintenance contracts available and
the maintenance performed/scheduled.

What pieces of information will you keep on customers? Each piece of information
will become a field. This data should be in a logical order. Think about the order in
which you would get the data from the customers.

Remember: Planning Is Vital!


It is important to start with some sample data and then to plan your field attributes
on paper. The following issues should/could be considered:

What should it be able to do? How will we be using it?


Hammer Wines Pty Ltd, for example, require:
 a customer contact list including names of associated venues for each
customer,
 records on the taps installed, when installed, who is the tap supplier,
 detailed records of the installation costs for all taps,
 the maintenance performed and a schedule of maintenance call outs, and
 an analysis of the problems encountered by venues with the taps supplied.

Access Workshop 1 Page 3


Activity 1
Office 2010

What reports do we want the system to produce? What data is on


them?
 List of the customers showing all postal and other contact information
including the name of the contact person and how to contact them directly
and the venues they operate.
 A list of taps supplied.
 Maintenance problems will need to be reported and analysed every 6
months.
 A report showing how much it costs to install taps at the various venues.

What information do we need in the Customer table to do these


things?
 List the data fields that you think will be needed.
Note: State and Postcode cannot be part of one field called Address as we will want
to use them independently. Do you need to store the contact person’s name as one
or two pieces of information? How will you use this information? Are you likely to
send them a personalised letter? If so, they will need to be stored separately.
 A general ‘rule of thumb’ is store data in its smallest parts. E.g., first name
and last name fields rather than simply a name field (you can then sort by last
name).
 Another consideration when deciding on fields is to avoid using calculated
fields. A calculated field is one that could have been derived from other
information. It could be subject to change (e.g., use date of birth rather than
age, and then calculate age at the time of use). It could waste space (do not
hold Net Pay if you’re already holding Gross Pay and Deductions). If you are a
catering company do not hold Total Cost if you already have Cost per Person
and Number Attending.

Reducing Input Error


The design should ensure the data is as correct and complete as possible. E.g.,
should ‘Contact telephone number’ be mandatory? Should it be possible for
‘Quantity Supplied’ to be zero? The more you put into the design of your tables the
easier it will be to create the forms.

You need to think about field properties for each field in each table. For example,
the majority of your customers might come from the state of Victoria, so use the
default value “VIC”. It is customary to capitalise this on letters, so format it for
capitals. Plan the layout of phone numbers, e.g., (03) 9888 1234 by modifying an
input mask to suit your needs. The field size should be adjusted according to the size
of the data to be entered; count the spaces, brackets and numbers. You need to
think about each of these features for every field. Adjustments to field size will have
an overall impact on the size of the database file in the longer term. Can a Customer
ID exist without a Customer Name? NO, then this field is required. Imagine that you
take a phone booking; at the very least you would input the customer name and a
phone number. These would be required.

Access Workshop 1 Page 4


Activity 1
Office 2010

You see how important it is to be familiar with how the database will be used. If
there is any data that might be repeated, it should ring warning bells and the
designer of the database should start looking for ways to eliminate input errors.
Think of how that data will be used; Suburb, for example, would be used in mail
outs. It is customary for this to be in capitals, so format it accordingly. The data
operator should not have to think about this. Access can automatically capitalise the
entry. It is acceptable to have abbreviations for field names, but use captions for a
professional appearance to your work.

The common symbols for input masks are 0, 9, L, >, <, \. Use Help and type examples
of input masks into the search area and learn how these are used. Access comes
with a number of sample databases. It is worth looking at the tables in these and
their properties.

Implement the Design


Now that we've thought about the fields required in the database tables, we will
begin to set it up in Access.

Note: The file that you created will be saved first, unlike a document in Word or a
workbook in Excel where you can save the file later. Also unlike those applications,
you will also have to save the objects (tables, forms, queries, reports etc.) within the
Access file as you work on them.

Open Access, select Blank Database, Figure 3 should appear.


You must give the database a name – Hammer _xxx.accdb where xxx
represents your initials.

Figure 3 – Database window

Access Workshop 1 Page 5


Activity 1
Office 2010

Customer Table
Importing Data from MS Excel
Many businesses when moving to a computerised database may have previously
used Excel to store some of the data. It is easy to convert this data into a table within
Access and then to improve on the design elements after the data has been
imported from Excel. Access can import or export data into or out of the other
Microsoft packages found in Office Professional. We will import data from Excel for
some of the tables to be created for Hammer Wines Pty Ltd to save time creating the
tables. Normally tables are created from scratch.

First we need to close table 1 – we don’t want to save this table.


Close by clicking on the X in the right hand corner of the table.
Step 1: Click on the External Data tab, Import section, Excel, and
navigate your way to the files you have copied to your removable
storage device, select Customers.xlsx. Accept the defaults, and then
click the OK button.
Step 2: Data will be stored in a New Table. Click Next. This will start
the import wizard (see Figure 4) that will step you through the
process. Click on Next.

Figure 4 – Import wizard

Step 3: Make sure that you check the box First Row Contains Column
Headings (see Figure 5). Click Next twice.

Access Workshop 1 Page 6


Activity 1
Office 2010

Figure 5 – Import wizard

Step 4: Access recommends you set the primary key. One field in the
table should be used to uniquely identify each record. This field is
called the Primary Key.
 When you want to find a friend’s address and phone number
in your address book you search for them by name.
 Your student number is the key in your university’s database.
 Car registration is unique to a vehicle.

These keys are unique. They let you find a particular record. Do we have a unique
field in our customer table we could use as a key? Company Name? Names are not
always unique; hence your student numbers are used in your university’s database.
Customer ID will be our primary key.
Let Access add primary key. Then click Next.
Step 5: Access will suggest a table name – Customers, click on Finish.
Step 6: We will not save the import steps, close.
Double click on the Customers table and check that all the data has
been imported. There should be 7 records.

Design view
Design view allows you to design your table – the field names, the type of data
they’ll hold. Descriptions can be added to those fields whose entry would benefit
from a little explanation and you can add any validation rules you wish to include.
Click on the Home tab, Design view icon, to edit the fields for the
Customers table.

Access Workshop 1 Page 7


Activity 1
Office 2010

Edit the field name for each field – keep them short but meaningful
without any spaces (refer to Table 1 below).
Each field also needs a data type to restrict the type of data that can
be entered into the field (see Table 1 below).
A description can be added to help users understand the type of entry
required.
Next, implement the field properties you’ve decided on. We do this
by setting up field properties or characteristics for each field (see
Table 1 below). Use captions to insert a more descriptive label to be
used as a column heading in the table, e.g., for field CMobile, the
Caption should be Mobile. For CPhone click on the build icon .
Remember to adjust the area code to reflect the number of digits in
your area, same for CMobile.
Note: Access provides context-sensitive help on any topic. For example, to see the
characters available for input masking, just put the cursor on the property box’s
Input Mask and then press F1 key on your keyboard.

Your planning should help to streamline this process, as you have thought it all
through!!

You should alter the properties for the fields as shown in Table 1 below.

Access Workshop 1 Page 8


Activity 1
Office 2010

Field Properties
Field Type/Size Description Default Validation
Size Format Input Mask Caption Required
Value Rule
CID AutoNumber Customer ID ID
CName Text Customer name 40 Customer Yes
CAddress Text 40 Address
CSuburb Text 30 >  Suburb
State Lookup wizard… 3 > VIC

PostCode Number 0000 P’code
CPhone Text Head office phone 15 Use build icon  Phone Yes
CFirst Text Contact person 25 First Name Yes
CLast Text 35 Last Name Yes
CMobile Text Contact’s mobile 15 Use build icon  Mobile Yes
CDirect Text Contact’s direct line 15 Use build icon  Direct Line Yes
Email Text Company email 50
address, if known
Table 1 – Field properties for Customers table

Explanation of Design Properties


 This symbol > will capitalise the entry, i.e., vic becomes VIC.
 Use a lookup wizard for state:
Select I will type in the values I want. Click Next
Enter each state (VIC, NSW, SA, WA, QLD, NT, TAS, ACT – use the down arrow on the keyboard to enter the next state, click Next.
The label for the lookup column will be State, click Finish.
 Click in the in the input mask area, the build icon will appear, click on this to open a wizard to adjust the phone to suit Australian conditions,
i.e., with a 2 digit area code (03) 9925 5995. You will need to edit the first phone number to read !\(99) 9900\ 0000
 Similar to the above but you will need to remove the brackets and add some digits so the mobile number reads 0000\ 000\ 000
Other alterations can be included as you deem appropriate. Discuss with your tutor.
Save the table.
Access Workshop 1 Page 9
Activity 1
Office 2010

Datasheet view
You are now ready to enter data into your table. For this you need to change to
the datasheet view of your table.
Use the toggle key to change the view. Enter the following
data into the blank row at the bottom of the Customer table: Aero Bar
Pty Ltd, 239 Aeroplane Ave, Essendon, Vic, 3870, (03) 9657 8832,
James Jelly, 0402 578 845, (03) 9657 8845,
jamesjelly@aerobar.com.au.
Save the table.
Close the table.
The completed table should look as follows in Figure 6 (note this does not show the
email column).

Figure 6 – Customers Table

Did you know that Access works exactly like Excel when widening columns? Go to
the line dividing 2 columns with the mouse until the mouse changes to a double
headed arrow, either double click or click and drag to resize the column.

Access Workshop 1 Page 10


Activity 1
Office 2010

Activity 2
Problem/Opportunity
Hammer Wines Pty Ltd staff would like to be able to see the details of the venues
owned by customers, as well as the customer details we have just set up.

Data Redundancy
We could simply add the venue details into our Customers table. If a customer
operates more than one venue we will have to repeat their customer information on
each record. This method can lead to problems. What if the customer moves office?
We will have to change their address details on each of the records we hold for them
for each venue. This problem is called data redundancy. We are repeating the same
information.

If we set up two tables; one for the customer details and one for the venue details,
we remove the redundant data by only holding the customer details once. Note, we
will need to indicate in the venue table which customer a venue belongs to – more
on this later!

Design Assumptions
Before we move on and set up the venue table, we need to state the assumptions
we are making about our data and how it affects the design of our database.

 A Venue will not be entered into the database unless it is operated by a


Customer.
 A Customer can operate more than one Venue (the more the merrier!), but a
Venue can only be operated by one Customer.
 Only a Venue operated by a Customer can have a Tap installed (we will have
to design another table, for the tap, later!)

Venue Table
Importing Data from Excel
As in the previous activity, Access can import or export data into or out of the other
Microsoft packages found in Office Professional. We will import data from Excel for
the Venue table.

Click on the External data tab, Import section, Excel (see Figure 7),
navigate your way to the files you have copied to your removable
storage device, select Venue.xlsx, accept the defaults, OK.

Access Workshop 1 Page 11


Activity 2
Office 2010

Figure 7 – Importing Data

As the first row of the data contains columns headings – make sure
this is checked.
Follow the same steps as shown in Table 1 in Activity 1 to import file
Venue.xlsx and setup the Venue table. Again, let Access add a primary
key.
Open up the Venue table you have created and check that all the data
has been imported.
Change to Design view and alter the table to reflect the field
properties in Table 2 below.
Save the table as Venue.

Access Workshop 1 Page 12


Activity 2
Office 2010

Field Properties
Field Type/Size Description Default Validation
Size Format Input Mask Caption Required
Value Rule
VID AutoNumber Venue ID ID
CID Number
Venue Text Venue name 40 Venue Yes
VAddress Text Delivery address 40 Address Yes
VSuburb Text 30 > Suburb Yes
VState Text  3 > State VIC Yes
VPostCode Number 0000 P’code
VPhone Text Venue phone 15 Use build icon  Phone Yes
VContact Text On site venue 35 Manager Yes
manager
VEmail Text Company email 50 Email
address, if known
Table 2 – Field properties for the Venue table

Enter a V in front of each field to distinguish them from the fields in the Customers table.
 Again use the lookup wizard for the field VState, see Table 1.
 See Table 1 in Activity 1 for use of build icon in the Input Mask field property of Phone.

Access Workshop 1 Page 13


Activity 2
Office 2010

We need a link between our tables. We need to relate the tables to each other.
Then, for example, we can look up a venue in the Venue table and find the phone
number of the customer who owns it.

Relational Databases
This is where the term, relational database, comes into our design process. The real
power of Access is derived from the creation of multiple tables and the relationships
that can be created between them. We set up relationships between our tables so
we can move between them gathering the data we need. Relational databases
reduce data redundancy because they can link related files using a common or key
field, without the need to repeat data inputted.

Type of Relationship Explanation


one-to-many Here a record in Table A can have many matching
records in Table B, but a record in Table B has only one
matching record in Table A.
In our Hammer Wines Pty Ltd database, it would mean a
customer can operate many venues but a particular
venue can only be operated by one customer.
many-to-many Here a record in Table A can have many matching
records in Table B, and a record in Table B can have
many matching records in Table A.
This type of relationship is only possible by defining a
third table (called a junction table). A many-to-many
relationship is really two one-to-many relationships with
a third table to separate them.
one-to-one Here each record in Table A can have only one matching
record in Table B, and each record in Table B can have
only one matching record in Table A. This type of
relationship is not common, because most information
related in this way would be in one table.
You might use a one-to-one relationship to divide a table
with many fields, to isolate part of a table for security
reasons, or to store information that applies only to a
subset of the main table.
Table 3 – Types of relationships

Now we have two tables and can start recording venues’ details in the Venue table.
BUT, how do we know which Customer a Venue belongs to? Which Tap each Venue
has installed?

Building a Relationship
The first step is to include a field that will link the Venue table to the Customers
table. The imported part already has been set up with the CID.

Remember the Customer should already exist in the Customers table. A Venue
cannot be operated by a Customer not already recorded in the Customers table,

Access Workshop 1 Page 14


Activity 2
Office 2010

otherwise we do not have details of the customer before we allow them to operate a
venue.

Now we know which customer operates which venue. We’ll also see that several
Customer IDs appear in the Venue table. In other words, the Customers table will be
the ‘one’ table (remember, each venue recorded in the table will only have one CID),
and the Venue table will be the ‘many’ table (one CID will appear many times in the
Venue table).

CID serves as the linking field between the two tables. The primary key of the one
table (Customers) is added to the many table (Venue). It is the primary key for the
Customers table, and the foreign key for the Venue table. But when we add a new
venue, we want to lookup the Customer ID and select the appropriate data.
In the design view of the Venue table, change the data type of CID to
Lookup Wizard…
Select I want the lookup column to look up the values in a table or
query, click Next twice.
Add the fields CID and CName by clicking on the > symbol (see Figure
8), click Next twice.

Figure 8 – Lookup Wizard

Adjust the column width, click Next.


The label for this look up column will be CID, Enable Data Integrity
should be ticked. This will ensure the customer exists is the customer
table. Click Finish.
Save the table, and then close the table.
Now, look at the datasheet view, the customer column should now show the names
of the customers rather than the CID.

Access Workshop 1 Page 15


Activity 2
Office 2010

Defining a Relationship
Now we are ready to link both tables. Close all tables and return to the main
database window.

Figure 9 – Relationship icon

Select the Database Tools tab and click the Relationships button (see
Figure 9).
The tables should be visible with a fine line connecting them. Notice
the primary key of each table has a key icon to the left of the field
name.
Click and drag the key field (CID), from the one table (Customers),
and drop it on the matching field (CID) in the many table (Venue).
Click on YES, you want to edit the relationship.
Check Enforce Referential Integrity as shown in Figure 10 and click
OK.

Access Workshop 1 Page 16


Activity 2
Office 2010

Figure 10 – Create relationship

Enforcing Referential Integrity


Enforcing referential integrity means the data in your tables must ‘hang together’.

 Access will prevent you from adding records to a related table where there is
no associated record in the primary table, i.e., you can’t link a venue to a
customer in the Venue table if you haven’t entered that customer in the
Customers table first.
 Access will prevent you from deleting records from the primary table when
there are matching records in a related table, i.e., you can’t delete a
customer from the Customers table if there are venues belonging to this
customer in the Venue table.
The relationships window will now look like Figure 11 below. You may need to
expand the tables to make all fields visible.

Access Workshop 1 Page 17


Activity 2
Office 2010

Figure 11 – Relationship window

Close the relationship window.


Save changes to the layout of the relationships, click Yes.

Adding Records to the Database


We have now set up our two tables and defined the relationship between them. It’s
time to add some data to our Venue table. We could enter the data directly into the
datasheet view of the table as we did for the Customers table, and directly relate
each venue to a customer. With Access 2010 it is possible to add a venue record
from the Customers table, simply by clicking the ‘+’ sign at the beginning of each
Customer record.
Click on the plus symbol next to the CID (as shown in Figure 12) to do
this.

Figure 12 – Datasheet view of two related tables

As displayed in Table 4, add the 2 venue records for Aero Bar via the
Customers table.
Venue Address Suburb State P’Code Phone Contact
TakeOff Level 2, Tullamarine VIC 3043 (03) 8318 4587 Jason
Bar Airport Dr Jelly
Don’s 239 Essendon VIC 3870 (03) 9657 8832 James
Plane Aeroplane Janko
Bar Ave

Access Workshop 1 Page 18


Activity 2
Office 2010

Table 4 – Additional Venue records for Aero Bar

Save and Close the table.


Open the Venue table and check the records. Close the table when
you have finished checking.

Did you know that you can remove any extra empty fields by right clicking on the
column heading and choosing hide? To display any hidden fields, right-click any
column heading and place a tick in the fields you want to display.

The finished Venue table should resemble Figure 13, with the Email field hidden.

Figure 13 – Datasheet view of Venue Table

Access Workshop 1 Page 19


Activity 2
Office 2010

Activity 3
Problem/Opportunity
Hammer Wines Pty Ltd staff will need to know which tap types have been installed in
which venues. We already have information about venues, we need to set up
another table, the Taps table. Once again, we need to state the assumptions we are
making about our data.

Design Assumptions
 The tap costings will be done in an Access. There are 3 types of taps that can
be installed. The taps types will need a table of their own which will include
costs associated with installation of each tap type.
 A Tap will not be entered into the database unless it has been installed in at
least one Venue.
 Each Venue can have many Taps. A particular tap can only be installed in a
Venue.

TapType Table
We will set up the TapType table first. As it is a small table with only 3 records we
will set this up from scratch.
Click on the Create ribbon, select Table section, click on the Table
Design, save this table as TapType.
The field are as follows in Table 5:
Field Properties
Field Data Type Description
Size Format Caption Required
TTID Autonumber “TT”00 Tap Type ID
TType Text Tap type 8 Type Yes
TTInCost Currency Initial tap Initial Cost Yes
cost
TTInstal Currency Installation Installation Yes
fee Fee
Table 5 – Field properties for TapType table

The primary key will be TTID, as it uniquely identifies each record.

For both TTInCost and TTInstal in the field properties, we are going to add a
validation rule and associated text. This rule will reduce data input error by only
allowing entries greater than $5,000 for TTInCost and $1,000 for TTInstal.
Adjacent to the Validation rule for TTInCost add the following: >=5000.
Save the table, click on datasheet view.
Add the data as shown in Figure 14 below.

Access Workshop 1 Page 20


Activity 3
Office 2010

Figure 14 – Datasheet view of the TapType table

If a value is entered that is greater than that which is allowed, the user will get an
error message from Access. The error message is a default one which is difficult to
understand. An entry in the validation text area will overcome this.
Go to the Design view.
In the Validation text area, we will add the explanation: Amounts
entered must be greater than $5,000.
Repeat the same process for TTInstal where amounts must be greater
than $1,000.

We want to link this table to the Taps table. As one TapType can have many taps, for
example we can install many quad taps in a variety of venues, and each venue can
have many taps. A venue may have an upstairs bar and a downstairs bar with taps
installed in each bar. This is a many-to-many relationship.

Tap Table
A many-to-many relationship, requires us to establish another table – the Taps table
to provide the link between the TapTypes and the Venue tables.
To import file Taps.xlsx and setup the Taps table, follow the same
steps as shown in Table 1 in Activity 1. In this case, the TAssetNo
should have Yes (No Duplicates), see Figure 15.

Figure 15 – Step 2 choose Yes (No Duplicates)

Select Choose my own primary key. TAssetNo will be used as the


primary key. Select Next.
Finish and close, saving the table as Taps.
Now for the design elements, open the Taps table in Design view.
Access Workshop 1 Page 21
Activity 3
Office 2010

Field Properties
Field Data Type Description Size Format Caption Input Required
Mask
TAssetNo Number
Vid Number Select from list Venue Yes
TSupplier Text Select from list 15 Supplier Yes
TTID Number Select from list Tap Type Yes
TPDate Date/Time Purchase date Short Date Purchase Use build Yes
of tap, Date icon
dd/mm/yyyy
Table 6 – Field properties of Taps table

For the TPDate field, click on the build button, select short date. Don’t
forget to trial inputs (see Figure 16 for the finished Taps table).

Figure 16 – Taps table

Close the Taps table.

Linking Tables
We will link the Taps table to the Venue table, bearing in mind that one Tap can be
installed in one Venue, but one Venue can have many Taps installed. Therefore we
need to include Vid (the primary key of the Venue table) in the Taps table, creating a
one-to-many relationship.

Moreover, to facilitate data entry, we would like to have the Tap Type (TTID) field in
the Taps table to ‘look up’ the TapType table from which the end user can select an
ID. But as the end user may not know the IDs from memory, we will use a query to
help us. A query is a means of questioning a database.

Access Workshop 1 Page 22


Activity 3
Office 2010

Go to the Create ribbon, Query Design view.

Figure 17 – QryVenue query to link tables

Add the Customers and Venue tables, by selecting each table


separately and clicking on Add. The tables should appear as shown in
the top section as Figure 17 above.
Close the dialog box.
Double click on the Venue field from the Venue table to add it to the
table at the bottom of the screen.
Repeat to add VID from the Venue table and CName from the
Customers table as shown in Figure 17 above.
The Query is complete, close the query and save as QryVenue.
Go to the Taps table, in design view.
Select Vid.
In Data Type area, click the down arrow and click the ‘Lookup
Wizard…’
In the dialog box, check the ‘I want the lookup column to look up the
values … etc.’ button. Click Next.
Select the Queries option as shown in Figure 18 below, then click
Next.

Access Workshop 1 Page 23


Activity 3
Office 2010

Figure 18 – Lookup wizard

To add all the fields in this query, click on the >>, then click Next
twice.
To widen the columns move the mouse between the column headers
as you would in Excel and double click, then click Next.

Figure 19 – Lookup wizard

Select VID as the value that you want to use in the database (see
Figure 19 above). Remember, we want this value to link the Venue
table and the Taps table.
Click Next, and Finish up the process.
Save the Taps table.
Continue anyway? YES.

Access Workshop 1 Page 24


Activity 3
Office 2010

Lookup Tab
Go to the datasheet view of the Taps table, click in TTID for the first record. You have
just created the drop down list. But we cannot see all the details. Once again move
to the design view. In the field properties section, you may have noticed the Lookup
tab, and a General tab.
Click on the Lookup tab, refer to Figure 20.

Figure 20 – Lookup tab

Change the Column Widths (see Figure 20 above) to read: 4.5cm;


1.5cm; 4cm.
Change the List Width to read: 10cm.
Now change to the datasheet view and look at the Venue ID, using the
drop down button.
We are now going to create a list box for Suppliers to make it more accurate for the
end user. Currently we have only 2 suppliers: Fass and Weizen. Once again, change
to the design view and select the TSupplier field.
In the Data Type area select Lookup Wizard, in the first screen of the
wizard use the second option I will type the values that I want, click
Next.
Use the down arrow to add the names of the 2 suppliers, click on
Next.
The Lookup column can have the label Suppliers, click Finish.
The Lookup tab should resemble the Figure 21 below.

Figure 21 – Design View, Lookup tab for Supplier field

Access Workshop 1 Page 25


Activity 3
Office 2010

We have one final change to be made; the TapType field (TTID) needs to be linked to
the Tap Type table in a similar way as we did with our customers and their venues.
Once again move to the design view and select the TTID field.
In the Data Type area, type Lookup Wizard…
Accept the default and click Next.
The Tap Type is going to come from the TapType table, select it (see
Figure 22 below), click Next.

Figure 22 – Lookup wizard

Select the fields TTID, TType by using the >, click Next 3 times.
The label for this lookup column should be Tap Type, click Finish.
Click YES twice.
Now go to the datasheet view and look at the improvements we have made. Add the
following new tap.
TAssetNo Venue Supplier Tap type Purchase Date
8754 Takeoff Bar Weizen Double 01/11/2010
Table 7 – New tap details to be added to the Taps table

The finished Taps tables should be as follows in Figure 23.

Access Workshop 1 Page 26


Activity 3
Office 2010

Figure 23 – Completed Taps table

Access Workshop 1 Page 27


Activity 3
Office 2010

Activity 4
Problem/Opportunity
Hammer Wines Pty Ltd needs to store data on the maintenance costs associated
with each tap in order to determine how much it will charge its customers. We have
one final table to create the Maintenance Contract table. This table will have the
names of the maintenance contracts and the costs associated with each type of
contract. All contracts are for a 24 month period. Customers can choose to have:
 Fixed price,
 Variable,
 Negotiate.
A fixed price contract will mean that all callouts are included in the price of the
contract. For example, $1000 will be charged for each tap unit installed in the
customer’s venue. If the customer has 3 venues it will be $1,000 for each tap, a total
of $3,000.

A variable contract will mean customers are charged per ½ hour visit to fix any
problems they are experiencing.

If customers have more than 5 taps installed across a number of venues, then we
have a discounted contract of $300 per unit.

Maintenance Contract Table


We will setup the Maintenance Contract table. As it is a small table with only 3
records we will set this up from scratch. The primary key will be MCID.
Click on the Create ribbon, select Table section, click the Table
Design, save this table as MaintenanceContract.
The fields are as described in Table 8.
Field Properties
Field Data Type Description
Size Format Caption Required
MCID Autonumber “M”0 Contract ID
MCType Text Maintenance 10 Contract Type Yes
contract type
MCCost Currency 12 month Contract Cost
contract cost,
if applicable
MCFee Currency Maintenance Maintenance
fee per ½ hr Fee per ½ hr
callout
Table 8 – Field properties for the MaintenanceContract table

For MCFee in the Field Properties, we are going to add a validation rule and
associated text. This rule will reduce data input error by only allowing any entries
less than $200.
Adjacent to the Validation rule add the following: <200

Access Workshop 1 Page 28


Activity 4
Office 2010

In the Validation text area, we will add the explanation: Amounts


entered must be less than $200.
Save the table, click on datasheet view.
Add the data as shown in Figure 24 below.

Figure 24 – MaintenanceContract Table

Design Assumptions
We now need to ensure that each tap has a maintenance contract of some sort. If
you think carefully about the connection between taps and their maintenance
contracts, you will realise that a tap can have only one maintenance contract, whilst
a maintenance contract type will be used for many taps. We therefore need to
include the primary key of the one table, in this case the MCID, to the many table,
the Taps table.

Go to the Taps table, in the Design View, add a new field as follows in
Table 9.
Field Properties
Field Data Type Description
Size Format Caption Required
MCID Lookup Contract ID Yes
Wizard…
Table 9 – Adding a field to the Taps table

Use the Lookup Wizard to create the link to the MaintenanceContract table.
Select I want the lookup column to look up the values in a table or
query, then click Next.
Select the MaintenanceContract table from the list, then click Next.
Add the first 2 fields, MCID and MCType, using the >, then click Next 3
times.
The label for this field will be Contract ID, now click Finish.
Go to the datasheet view, and enter the Contract ID for the different
customers as shown in Figure 25 below.

Access Workshop 1 Page 29


Activity 4
Office 2010

Figure 25 – Maintenance contract for each tap

Did you know that you can click the Refresh All button on the Home tab? This will
update any records you have entered that are currently not displayed when you are
looking at the table data.

Access Workshop 1 Page 30


Activity 4
Office 2010

Activity 5
Creating Relationships
We need to link the tables created so far. This will enable the user to question the
database and draw answers from fields in connected tables

Access will show all the tables created and the possible connections between our
tables created as a result of the lookup wizards.
Select the Database Tools ribbon, click Relationships button.
Click on All Relationships, (See in Figure 26) if not all tables are shown
click on Show Tables and add the tables.

Figure 26 – Relationships Window

We have one more relationship to create between Venue and Taps.


Using the mouse, click on VID in the Venue table and drag on to the
Venue in the Taps table. This will open the Edit relationships dialog
box.
Click on Enforce Referential Integrity, click OK.
Click Close the relationship window using the toolbar.
Save the layout of the relationship.
The relationship should now resemble Figure 27.

Figure 27 – The completed Relationships Window


Access Workshop 1 Page 31
Activity 6
Office 2010

Activity 6
Problem/Opportunity
One of the major reasons for creating the database is to keep track of servicing, both
scheduled and non-scheduled. Scheduled servicing is required for all taps on a
quarterly basis. Whilst some customers may experience problems that require
service visits at other times, these are known as unscheduled services.

Database Design Assumptions


Before we move on and set up the Service table, we need to review the assumptions
we are making about our data and how it affects the design of our database.
 A Maintenance Contract can be associated with many Taps.
 A Tap can only have one Maintenance Contract.
 A Customer can have many Venues.
 A Venue can only be controlled by one Customer.
 A Venue can have many Taps.
 A Tap belongs to only one Venue.
 A Tap Type can have many Taps.
 A Tap can belong to only one particular Tap Type.
 A Tap can have many Services.
 A Service is for only one Tap.
The service records have been kept in Excel until now, so we will import that data.
Follow the same steps shown in Activity 1 to import file, Service.xlsx,
click Next (see Figure 28).
ServID will be our Primary Key so Let Access add primary key, click
Next.

Figure 28 – Maintenance contract for each customer

Finish and close, saving the table as Service.

Access Workshop 1 Page 32


Activity 6
Office 2010

Now for the design elements, open the Service table in Design view.
Field Properties
Field Data Type Description
Size Format Caption Input Mask Required
ServID Autonumber
SDate Date/Time Service date of tap, Short Date Service Date Use build icon Yes
dd/mm/yyyy Select short date
99/00/0000
TAssetNo Text Select from list  Yes
TSerialNo Text 3 digit number starting with S, 5
D or Q
UnitTime Number Number of 1/2hour blocks Units of Time Yes
taken to complete service
Problem Text Select from list
Scheduled Yes/No Is this a scheduled service? Scheduled?
Completed Yes/No Is this service completed? Completed?
Table 10 – Field properties of the Service table

 By creating a query called QryTap as follows:

Go to Create, select Query Design.


Add the Venue and Taps tables, by selecting each table separately and clicking on Add.
Close the dialog box.
Double click on TAssetNo from the Taps table, double click Venue, VSuburb and VState from the Venue table.
The Query is complete, close the query and save as QryTap.

Access Workshop 1 Page 33


Activity 6
Office 2010

Create the QryTap query as directed above.


Go to the Service table in Design View.
Select TAssetNo.
In ‘Data Type’ area, click the down arrow and click the
‘LookupWizard…’
In the dialog box, check the ‘I want the lookup column to look up the
values… etc.’ button. Click Next.
Select the Queries, Query: QryTaps, click Next.

Figure 29 – Maintenance contract for each customer

Send across all the fields available by using >> (as shown in Figure 29),
then click on Next twice.
At the screen ‘how wide would you like the columns’, adjust as you
would to widen columns in Excel, by double clicking between the
columns headings. Ensure that you can see all entries by scrolling
through the list, click on Finish.

Let’s have a look at the datasheet view for the TAssetNo, can you see all the entries
when you click on the drop down arrow? See Figure 30.

Access Workshop 1 Page 34


Activity 6
Office 2010

Figure 30 – Service table: TAssetNo combo box

No, we need to adjust the column widths as shown in Figure 31 below.

Figure 31 – Service table: TAssetNo – field properties Lookup tab

Whilst in the design view, click on the Data Type area for the field
Problem, choose Lookup Wizard…
Select I will type the values that I want, click Next.
Enter the following problems as described in Table 11, using the down
arrow on the keyboard to move to the next entry as pressing the
enter key is the same as clicking Next. Use Problem as the label when
asked. Click Finish when done.

Table 11 – Problems in Service table

Access Workshop 1 Page 35


Activity 6
Office 2010

You will need to go to the Lookup tab to adjust the column width as
shown in Figure 32.

Figure 32 – Service table, Problem field – Lookup tab

Go to the datasheet view of the table and save changes.

The Service table should resemble Figure 33, below.

Figure 33 – Service table

Did you know that you can hide columns just like in Excel? To Hide columns,
Open a table in datasheet view.
Select the column(s) you want to hide.
To select one column, click the field selector for that column.
To select adjacent columns, click a column field selector and then,
without releasing the mouse button, drag to extend the selection.
On the Format menu, click Hide Columns.
Access Workshop 1 Page 36
Activity 6
Office 2010

Activity 7
Creating Relationships: Adding the Final Touches
We now need to link all the tables created so far. This will enable the questions we
ask of our database to be answered and for the user to create the reports required.
Select the Database Tools ribbon, click Relationships button.
Click on All Relationships, if not all tables are shown click on Show
Tables and add the Service table.
We need to create the connections between Taps and Service
Drag the TAssetNo in the Taps table to TAssetNo in the Service table
(one Taps can have many services, but only one service is for a
particular tap) to again open up the Edit Relationships dialog box (see
Figure 34), Enforce Referential Integrity, click Create.

Figure 34 – Creating relationships

Click Close the relationship window using the toolbar.


Save the layout of the relationship.
You can move the tables to make it clearer to see the relationships as seen in Figure
35.

Access Workshop 1 Page 37


Activity 7
Office 2010

Figure 35 –Relationships window

Access Workshop 1 Page 38


Activity 7
Office 2010

Design your own Database


How do you go about creating a database yourself?
 Firstly resist the urge to ‘just do it’.
 Databases need to be designed.
 It is far easier to change the design than the actual database later on.

There are many ways to go about designing a database. The following are a few
general guidelines:
 What should it be able to do? How will we be using it?
 What reports do we want the system to produce? What data is on them?

If we know what we want to get out of the database, we can ensure the appropriate
data goes in.

Design the table or tables you will need. A database is only as good as the validity
of its data. This data should be in a logical order. Think about the order in which you
would get the data from customers, for example. Add explanations of the fields in
the description area of the design view.

Use the following empty table as a guide to working out the data on Customers that
should be held in the database.

Access Workshop 1 Page 39


Activity 7
Office 2010

Field Properties
Field Type/Size Description Default Validation
Size Format Input Mask Caption Required
Value Rule

Table 12 – Customer data to be held in database

Access Workshop 1 Page 40


Activity 7
Office 2010

Skills Developed
You now know how to:
 Import data from Excel into tables.
 Design tables to reduce input errors and aid accuracy of the data.
 Create relationships, enforce referential integrity.
 Add data to a table.
 Create a drop down list box as a method of data entry.

Congratulations for your first database! In the next workshop


you will discover ways to more easily edit and view your data as well as
making your database more user-friendly.

Access Workshop 1 Page 41

You might also like