Professional Documents
Culture Documents
Access Workshop 1
Access Workshop 1
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:
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.
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.
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.
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.
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.
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.
Step 3: Make sure that you check the box First Row Contains Column
Headings (see Figure 5). Click Next twice.
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.
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.
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
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).
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.
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.
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.
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.
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.
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.
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,
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.
Defining a Relationship
Now we are ready to link both tables. Close all tables and return to the main
database window.
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 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.
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
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.
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
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.
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.
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).
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.
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.
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.
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.
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.
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
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.
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
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.
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.
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.
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.
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
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.
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.
You will need to go to the Lookup tab to adjust the column width as
shown in Figure 32.
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.
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.
Field Properties
Field Type/Size Description Default Validation
Size Format Input Mask Caption Required
Value Rule
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.