Microsoft Office/Create a basic two table database with reports

Vocabulary

 * Database - a collection of organized data that allows you to look up, edit or report on it.
 * Table -  Stores information about one specific kind of item
 * Record - The rows in a table that contain information about a given person, product, or event.
 * Field - The columns in a table that contain a specific piece of information like the city, state, or phone number.
 * Query - The ability to access the data by asking questions. Getting out all the companies that are in a certain city, or all the clients with the last name of Smith.
 * Forms - Attractive layouts used for entering or looking up records in a table.
 * Reports - Attractive layouts used for printing out the data with sophisticated presentation.
 * Web Page - A SharePoint for information that is stored in Access so it can be seen on the web.
 * Primary Key - a unique identifier for a record. There can be only one. Every record must have a different value in a field that is set up to be a primary key.  If it is a table of products and the PRODUCT ID is the primary key, no two records can have the same ID.
 * Data type - Specifying the type of data a certain field will hold. Access needs to know if you are going to work with a number, text, a time/date or a hyperlink.
 * Field Size - Specifying how large the field will be. Access needs to know how large a text box needs to be created to hold text type data.
 * Design view - A view that allows you to manipulate how data will be created, stored, and displayed on the screen and in reports.
 * Datasheet view - A view of a table that is much like a spreadsheet. It allows you to enter in your information quickly.
 * Report View - Once you create a report, you need to turn it to report view to preview it on the screen.
 * Form View - Once you create a form, you need to turn it to form view to enter data, or use if for lookup.
 * Form Layout - Once you create a form, you need to turn it to layout view if you wish to move items around on your form.
 * Report Wizard - A tool that allows you to create a report by simply choosing what table and fields in the table you want to display. The report is built for you very quickly.

What is a database?
A database is a collection of organized tables. Each table is a collection of related records. Each record gives information about one item and is made up of many fields. Each field is one specific piece of information.



In this figure you can see the Clients Table is open in the Access work area. It contains 10 records, one for each client. There are nine fields: Client number, Client name, Street Address, City, State, Zip Code, Amount Paid, Type of Advertisement, and Employee.

Guidelines
Before you start to create a database, there needs to be a lot of planning. The first question should be: What is the purpose of the database? I usually want to know, what do I want to be able to pull back out of the database. So I guess I work backwards from the reports to figure out what will need to be put in.
 * 1) What is the purpose of the database
 * 2) Who all will use the database
 * 3) What will each type of user need to be able to do
 * 4) *What reports does each user need
 * 5) *What forms does each user need
 * 6) *What transactions will each user need to document
 * 7) Determine the tables that you will need
 * 8) Determine the primary key fields
 * 9) Determine all other fields that you will need in each table
 * 10) Determine data types for each field
 * 11) Determine field size for each field
 * 12) Determine the relationship between the tables
 * 13) Determine what fields will need to link the tables together
 * 14) Remove any redundancy in the tables

Requirements
The yearbook staff need to keep track of their yearbook ad sales to the businesses in the community. In order to do this they will need to track the businesses of the community and what businesses have purchased ads, what types of ads they have purchased and if they have paid. They will also need to keep track of each student, in this case employee, to determine who has sold the ads. The staff will need to keep track of two basic groups of data, the businesses and the yearbook staff members. For this example we will call the businesses - Clients, and the staff members - Employees. For the clients we will need to know: For the Employees we will need to know:
 * Client Number
 * Client Name
 * Street Address
 * City
 * State
 * Zip Code
 * Amount Paid
 * Type of Advertisement
 * Employee Number
 * Employee Number
 * Last Name
 * First Name
 * Street Address
 * City
 * State
 * Zip Code
 * Number of Ads Sold
 * Dollar Value Sold

Name the tables and fields
We will call the two tables: Clients and Employees
 * They must not be longer then 64 characters
 * You can use letters, integers, spaces, and some punctuation marks
 * They cannot contain: periods (.), exclamation points(!), asterisks(*), question marks(?), accent marks(`) or square brackets([])
 * The same name cannot be used twice
 * Pick a logical naming convention so you can find your information quickly
 * Use upper cases to start words - Client Name
 * Use no space between words - ClientName
 * Use an underscore between words - Client_Name

Primary Keys
Each table needs to have a primary key. This is the one value in each table that can not be repeated, it is considered the look-up value. This field is used to easily access all the data for one record and usually has a short field length. For this example we will use the:
 * Employee Number
 * Client Number

Relationships between tables
When you design a database you need to be able to tie the data together. In most databases you have one table that is used once and tied to many records in another table. In this example the Client is used once, and each client is tied to an employee. So, each record in the employee table is used many times. This is called a One to Many relationship. Employee A works with
 * Client 1
 * Client 2
 * Client 3
 * Client 4

Data types
When you are creating the fields you also need to think about what type of data you are collecting in each field. Here is a run down of each data type:

Redundancy
The point to using a database instead of a spreadsheet is the ability to link tables together. This is useful for reducing redundancy. Redundancy is the repetition of the same data over and over again. For example if you are tying clients to employees, you would not want to have to tie the same employee name, address, city, state, and zip to every record. Instead you can link them both together with an employee number and store the data in separate files. By storing the data in separate file it reduces the risk that data will not be updated properly. Think about if an employee moves and the employee data is in the same table as the clients. You would have to go through all the records that had that employee and change the same data for each record that employee works with.

Client Table
From the Access Window click on the: Click on View and Design View Click on OK Then fill in the fields on the design view of the form to follow the structure of the table below. You will need to enter the field name, data type, and field size as the arrows above show.
 * Create Tab
 * Go to the TABLE Group on the far left of the ribbon
 * Click on the TABLE button

Once you are done putting in the field definitions then you will need to put in the data. Then you can enter the data just like a spreadsheet. HINT: If you do not like entering the data this way you can click on FORM and it will create a form for you to enter the data into a form.
 * Click on VIEW
 * Click on Datasheet View

After you are done putting in all the data for the Clients you are ready to create the table for the employees and put in that data. You will follow the same steps as above.
 * 1) Go to Create - Table
 * 2) Go to View - Design View
 * 3) Name the table Employees
 * 4) Set up the fields as list in the table below

Employee Table
Once you have created the fields for the table then go to VIEW - Datasheet View and type in the data as listed below.

Create a form
The easiest way to create a form is to have the table open that you want the form to populate. The from is created and you are in layout view. You can move items around from this view, but when you are ready to enter data you will need to change to Form View. Start entering data. If you want to look through the records then use the buttons at the bottom of the screen they are just like those on all the electric devices you all use today. If you want to enter new data then click on the button that is the blue arrow pointing right with a star. Enter in the new data for the first field
 * Click on the Create Tab
 * Go to the Forms Group
 * Click on FORM
 * Go to the HOME Tab
 * Click View
 * Click Form View
 * Press TAB to go to the next field
 * Press SHIFT+TAB to go to the previous field
 * Press TAB at the end of the fields on the screen will save that record and bring you to the next empty record.

Print a table
To print a table have the table open: NOTE: You do not have the printing control like you did with Excel, if you need a better format that is when we create a report.
 * Go to the Office Button
 * Click Print arrow
 * Click on Print Preview
 * Change it to landscape if needed
 * Adjust the margins if needed

Create a report

 * Close all the tables and forms.
 * Click on the CREATE tab
 * Go to the REPORTS group
 * Click on REPORT WIZARD
 * Set the table to Clients
 * Click on the greater than sign to move the selected field to the right (fields on the right are put into the report)
 * Move the following fields to the report:
 * Client Number
 * Client Name
 * Amount Paid
 * Type of Advertisement
 * Employee Number
 * Click on NEXT
 * For this report we will not do any groupings and will leave this for a more advanced topic
 * Click NEXT
 * Click the Drop down and choose the Employee Number (This will sort the report by employee number giving a list of clients for each employee.)
 * Click Next
 * Leave this set to tabular, you are welcome to play with this and see what each one will do.
 * click Next
 * Look at the different styles and choose the type that you like the best
 * Click on NEXT
 * Type in the name of the report
 * This is the name that will print across the top of the report so watch your typos
 * Click FINISH

Print a report
Go to the office button and click on PRINT

Project
Create a database to keep track of a business of your choosing. You must have:
 * multiple tables - most of you will need four tables
 * Client table (with at least 10 records)
 * Client number
 * First name
 * Last name
 * Street address
 * PO Box
 * City
 * State
 * Zip Code
 * Phone number
 * Employee number - depending on your business
 * other fields that fit your business
 * Employee table
 * Employee number
 * Last name
 * First name
 * Street address
 * PO Box
 * City
 * State
 * Zip Code
 * Phone number
 * Pay Rate (if this fits your business)
 * Other fields that fit your business
 * Inventory or Services table (depending on your business)
 * Item Code
 * Item Description
 * Item Cost
 * Sales or Appointment table (depending on your business)
 * Invoice number - auto number
 * Client Code
 * Employee Code
 * Time
 * Date
 * Service or item
 * Quantity of item or length of time on service (if this fits business)
 * You can have more tables to keep track of your business if you need
 * Create a form for entering data and looking up data
 * Create a report that matches your business such as:
 * Invoice
 * Billing Summary
 * Appointment Schedule
 * Turn in a print out of:
 * each table
 * each report