Professional Documents
Culture Documents
Project 01 - Create A Database - Millionaires (LP)
Project 01 - Create A Database - Millionaires (LP)
AS 91892 4 credits
Project 1 –
Creating a
Database
By J Murfitt
AS 91892 Database 4 credits
Quick Summary
Here is a quick summary of the tasks in this project. If you know what to do, just get on with it.
Otherwise, you will need to read the instructions on the following pages.
• Determine the data type (date, number, text, yes/no) for each piece of data you will store. (pg 2)
• Determine the size of each text field. (pg 3)
• List up all the fields and show their data type and size (design the structure of your database). (pg 4)
• You can calculate someones age using their birthdate, so you can leave out the age field (excellence). (pg 4)
• Create a new database and save it with an appropriate file name. (pg 5)
• Give the blank table an appropriate name (put “tbl” in front of the table name and don’t use spaces). (pg 6)
• Find out what AutoNumber data type are for. (pg 6)
• Set up the last name field as text with a maximum size of 20. (pg 7)
• Avoid using spaces in field names. (pg 7)
• Find out why you don’t leave a text field at 255 characters long (Merit). (pg 8)
• Short text vs Long text (pg 8)
• Set up the “Firstname” (max 20 characters) and “RichScale” (max 2 characters) fields and data types. (pg 9)
• Set up the “Birthdate” field and set it to display as a “medium date” (Excellence). (pg 9)
• Set up the “Height” field as a “byte” so it can store heights between 0cm and 255cm. (pg 10)
• Look at the difference between byte and single numbers (merit). (pg 10)
• Understand what a byte, integer, and long integer represent (Merit). (pg 10)
• Set up the “Gender” field with a field size of 1. (pg 11)
• Find out why a phone number is text, not a number. (pg 11)
• Set up the “MobilePhoneNumber” field and set it as text, 11 characters long (Merit). (pg 11)
• Set up “NetWorth” field with a “currency” data type (Merit). (pg 12)
• Set the “NetWorth” field to have no decimals places (Excellence). (pg 12)
• Set up “TaxEvader” field with a “Yes/No” data type. (pg 12)
• Set up “NetWorth” field with a “currency” data type (Merit). (pg 12)
• Set up “SourceOfWealth” field with size of 30. (pg 12)
• Summary of how to organise your information for merit, and present data effectively for excellence.
(pg 13)
By J Murfitt Page 1 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
Scenario
Read this
1. The US President has vowed to catch and detain all known millionaires.
Track –
Fast
US President Millionaire
2. The FBI keep records of millionaires on paper, but are finding they
need to upgrade their system to a computerized database. They
have asked you to help them set up their database.
a. They need a system to keep track of each millionaire (see below
for details of what data they will store).
b. They need to have queries that lets them find certain millionaires
based on certain criteria.
c. They need a form to let them easily add, modify or delete
millionaires from the database.
d. They need a report to list up all millionaire information, but they
need the report divided into rich and filthy rich millionaries.
Data Types
If you know how to do the task(s) below go to the next heading (page 3), otherwise read the instructions below.
▪ Determine the data type (date, number, text, yes/no) for each piece of data you will store.
3. For an Achieved you need to “design the structure of the data”. So, here is a sample
paper record that the FBI used.
4. Look at the data above and try to determine the data type of each field. Your choices are:
Date Number Text Yes/No
By J Murfitt Page 2 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
5. Here are the answers showing what each fields data type is. We will talk about why phone is “text”
rather than a “number” later on, but how many did you get right?
6. Using the table above, estimate the maximum size of each piece of text data.
Do this
So how long do we expect someones last name to be? There is no exact answer for this, but 20
might be a good place to start. But what is the chance we will have someone with a lastname longer
than that? We could go for 50 just to make sure, but every extra character we add will cost us
money. If you have to store every persons last name, and you have 1,000,000 names all 20 characters
each, that is approximately 20 million characters that need to be stored. If you set each lastname to
be a maximum of 50 characters, you now need 50 million characters to store. In the event that the
storage device you use isn’t big enough to have 50 millions characters (this is just an example), then
you would have to buy another storage device.
So we will say each last name will be a maximum of 20 characters long (but we could change that
later if we wanted to). Mobiles are 10 characters, but could be 11.
By J Murfitt Page 3 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
8. For now we will leave our “design the structure of the data” at this level. Later on we will talk about
dividing the data up into different tables (normalization).
9. Note that I have not included the AGE field. There are a couple of reasons for that.
a. If you enter in someones age as “15” into the database, in 2 years time their age will stillbe “15”
even though they are not that age.
Fast Track –Read this
b. If they are “15” in the database now, next month when they have their birthday the database will
still say they are “15”.
10. A better solution is to just record the persons birthdate. The computer knows what the current date
is, so it is easy to calculate a persons age if you know todays date and their birthdate.
11. For excellence you need to present the data effectively, which means to only include
relevant fields in a logical order. In other words, you don’t need the age field.
By J Murfitt Page 4 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
12. Open Microsoft Access (the purple/pink icon with the key).
Fast
As a side note, you should now know why these worksheets all have a “purple/pink” theme!
13. Access is different to other programs because you need to save your work before you start, as
opposed to saving it after. Look at the right hand side and you should see a place to type in a file
name, and also select the folder to save it.
14. For a merit you need to organize things logically. This means you need to
a. Save your work in a well named folder.
b. Save your database with a logical file name.
16. Incidentally, you can also just double click on the “Blank Database”
icon, but this will create a database with a generic name like
“Database1” into your home folder.
By J Murfitt Page 5 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
Setting up a Table
If you know how to do the task(s) below go to the next heading (page 6), otherwise read the instructions below.
▪ Give the blank table an appropriate name (put “tbl” in front of the table name and don’t use spaces).
18. Just as a reminder, a table is where you store all the information. For a student database, the table
would hold information about students. For a millionaire database the table will hold information
about our millionaries.
19. The first thing we need to do is tell the database what kind of fields will be required in this
database. Design view gives us more options, so click on the design view icon.
Fast Track –Do this
21. Remember that organizing things logically is required for merit, so using correct
naming is something that can help you gain a merit.
a. This includes adding “tbl” before the name of the table.
b. You should also not use spaces in table names, which is another merit concept.
Theory –AutoNumbers
If you know how to do the task(s) below go to the next heading (page 7), otherwise read the instructions below.
▪ Find out what AutoNumber data type are for.
25. The ID field is of type “AutoNumber”. When you have a few tables that are connected to each other,
you will need to use a uniqu number to identify records from another table. The “Autonumber” data
type automatically assigns a unique number to each record in the table. For now we don’t need to
use it, so you can either just leave the ID field as it is, or you can delete it if you want.
By J Murfitt Page 6 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
26. Let’s set up our millionaries “last name”, which will hold text. Note that if you don’t see the
same thing as shown below, click on the “Design View” button .
Track –
Do this
28. Next, press TAB to get to the next column (its faster than using the mouse.
select the type of data this field will be. Text is selected by default, so we will leave it as is.
29. Finally, we need to tell the database how many characters the longest lastnamecould be. You have
to guess a little here, but a field size of 20 should be big enough. You can change this to make it
larger later on.
30. Also note thatwe don’t use spaces when naming a field. In reality you can actually
add spaces, but this will cause problems later on as the database can sometimes think
a field called “student grades” is actually two fields, one called “student” and the
other called “grades”. To avoid this problem later on, it is easier to not use spaces in
the name of the field. Not using spaces in a fieldname is something aimed towards
merit.
By J Murfitt Page 7 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
32. Let’s say you set the length of “Lastname” to 255 characters. This tells the database to set aside 255
characters for each last name, regardless of how long the name actually is. As a result, when you
have 1000 people in your database, you are using 255,000 characters (255 x 1000).
33. If however, you set the maximum length to 20 characters, you would use 20,000 characters (20 x
1000). The end result is that your database won’t take up as much room on the disk (20,000 is 8% of
255,000, which is a huge savings in disk space)
34. So, when setting text length, look at your original data and estimate what the longest possible text
could be. If you make it too small, then some names won’t be able to be entered into the system. If
you make it too long, you end up wasting disk space.
35. The good news is that you can change this setting after the table has been created.
36. So for merit you need to structure and organize your data, so you would need to set up
your text fields using an appropriate field size length. This would mean you would
change the default text length of 255 to an appropriate number.
For merit, you will need to select the correct data type from the dropdown list.
By J Murfitt Page 8 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
“Date/Time”.
44. For excellence you need to present the data effectively, which means to set the
format for any date fields to display appropriately.
By J Murfitt Page 9 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
49. Just like we did for text, we are trying to reduce the amount of disk space our database will use. As
such, we need to tell Access what kind of number we will store as some number types take up more
space than others. To reduce confusion, we will just go over a few number types. There are more,
but we will ignore them for now.
Number Type Range Example
Byte Numbers between 0-255. We set height to byte. Not many
Can only be whole numbers (no decimals) people go over 255 cm tall.
Integer Numbers between minus 32,678 to 32,767. Used for large whole numbers under
Can only be whole numbers (no decimals) 32’ish thousand.
Long Integer -2,147,483,648 to 2,147,483,647 For large whole numbers.
Single Bigger than long integer, and can include For numbers requiring decimals,
decimal places. such as money etc.
50. A byte is one piece of memory, which can hold 1 character or 1 number between 0 and 255. Not many
people are over 255 cm tall so we can use a “byte”. . However, if we wanted to store height as
“1.8m” then we would have to use a “single”. The catch is that a single can hold very large numbers
so it would be more economical to use centimeters and use a date type of “byte”.
51. For an achieved you can leave your numbers as the default Integer or Long Integer,
but for merit you need to select the correct number type to show you are structuring
and organizing your data.
52. If you wanted to store “1.8” and used a byte, it would automatically convert to the whole number 2.
By J Murfitt Page 10 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
is enough.
54. Phone is a number, but we chose to use text. There is a good reason for this. The
only time you want to use a number is if you need to perform a calculation on it. You
may be saying that you probably won’t perform a calculation on “Age”, but you could
actually create a query that lists all millionaires over 20, which is a calculation. You
probably won’t create a query to list all millionaires with a phone number bigger than 1234567. The
other reason is that phone numbers often have a zero in front of them (like 07 for Hamilton). A text
field lets you enter “07”, where as a number field will convert 07 to just the number 7 without the
zero. Setting a phone “number” as “text” is something you would do for a merit.
By J Murfitt Page 11 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
61. Merit involves structuring and organizing your data, so setting a currency amount field
to “currency” is something you would do for a merit, as opposed to leaving it as a byte
or integer.
62. Excellence involves presenting data effectively, so setting an appropriate number for
decimal places in your table fields is something for excellence.
66. Our final field is called “SourceOfWealth”, or where the money came from.
67. Create a “SourceOfWealth” field with a data type of “Short Text”, size 30.
By J Murfitt Page 12 of 13
AS 91892 Database 4 credits
Project 1 – Creating a Database
68. For merit you also need to show evidence that your tables were created properly
(structuring, organising and querying the data logically). You would also do the
following…
• Save your work in a well named folder.
• Save your database with a logical file name.
• Add “tbl” before the name of the table.
• Not use spaces in table names.
• Not use spaces in a fieldname.
• Change the default text length of 255 to an appropriate number.
• Select the correct data type from the dropdown list (short text, long text etc)
• Select the correct number type (byte, integer, long interger, single etc)
• Setting a phone “number” as “text”.
• Setting a currency amount field to “currency”.
• Use of validation rules or input masks to ensure correct data entered (we’ll talk about what
this means later on)
For excellence you should present your data effectively, so would do the following
• Including only relevant fields in table, and in a logical order (so we didn’t include age).
• Setting date field formatting options.
• Setting the correct number of decimal places to display.
By J Murfitt Page 13 of 13