Database Mini Project

Embed Size (px)

Citation preview

  • 7/30/2019 Database Mini Project

    1/14

    Microsoft Access Database

    What is a database? It's an organized collection of data. A database management system

    (DBMS) such as Access provides you with the software tools you need to organize thatdata in a flexible manner. It includes facilities to add, modify or delete data from the

    database, ask questions (or queries) about the data stored in the database and producereports summarizing selected contents.

    Microsoft Access provides users with one of the simplest and most flexible DBMSsolutions on the market today. Regular users of Microsoft products enjoy the familiar

    Windows "look and feel" as well as the tight integration with other Microsoft Office

    family products. An abundance of wizards lessen the complexity of administrative tasksand the ever-present Microsoft Office Helper (you know the paper clip!) is available

    for those who care to use it. Before installing Access, be sure that your system meets

    Microsoft's minimum system requirements.

    Versions

    Access 1.0

    Access 1.1

    Access 2.x (Office 4.x)Access 95 (Office 95)

    Access 97 (Office 97)

    Access 2000 (Office 2000)

    Access 2002 (Office XP)

    Creating an Access Database

    To create a new database in Access follow these steps:

    1. Start Access2. From the menu choose File < New

    http://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/accesshttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/office/access/prodinfo/sysreq.mspxhttp://www.emsps.com/oldtools/msaccv.htm#access10%23access10http://www.emsps.com/oldtools/msaccv.htm#access11%23access11http://www.emsps.com/oldtools/msaccv.htm#acc2%23acc2http://www.emsps.com/oldtools/msaccv.htm#acc95%23acc95http://www.emsps.com/oldtools/msaccv.htm#acc97%23acc97http://www.emsps.com/oldtools/msaccv.htm#access2000%23access2000http://www.emsps.com/oldtools/msaccv.htm#access2002%23access2002http://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/accesshttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/office/access/prodinfo/sysreq.mspxhttp://www.emsps.com/oldtools/msaccv.htm#access10%23access10http://www.emsps.com/oldtools/msaccv.htm#access11%23access11http://www.emsps.com/oldtools/msaccv.htm#acc2%23acc2http://www.emsps.com/oldtools/msaccv.htm#acc95%23acc95http://www.emsps.com/oldtools/msaccv.htm#acc97%23acc97http://www.emsps.com/oldtools/msaccv.htm#access2000%23access2000http://www.emsps.com/oldtools/msaccv.htm#access2002%23access2002
  • 7/30/2019 Database Mini Project

    2/14

    3. The "New File" side bar will be displayed on the right-hand side of the screen

    4. Left-click the option "Blank database...", which will then ask you to name your database.Helpful Hint: Access databases are saved with the .mdb extension.

    5. Name your file (we chose TizagDB) and press Create. This will automatically save your blankdatabase, so remember where you put it!

    6. The Access Database interface should now be displayed and you are well on your way tolearning Access!

    Now that the database has been created we can begin to create our first Access Table. A tableresides within a database and holds information specific to a certain area.

    Access Tables

    A table in Access is quite different then a table in real life. Here's an example of a table in Access:

  • 7/30/2019 Database Mini Project

    3/14

    There are for key components we want you to learn right now:

    1. tbl_Sales: The name of our table is the example is "tbl_Sales". Note that we could havesimply called our sales table Sales, but by including a prefix tbl_there is absolutely noconfusion and is a great Access habit to pick up!

    2. Columns: A column is one vertical section of the table (i.e. up-and-down sections). Thevertical columns have their label at the top and these labels should describe the type ofinformation that will be stored. The columns in this table are: Employee, Product, Price and

    SaleNumber.3. Rows: A row is one horizontal segment of the table (i.e. left-to-right sections). One recordtakes up exactly one row. For example, in this table one sale at Bob's Shoe Store was a pairof slippers, which sold for $5.00. This record was entered left-to-right as follows: Employee-Bob, Product-Slipper, Price-$5.00, SaleNumber-3.

    4. Cells: A cell is simply the intersection of a row and a column. Can you find the cell thatcontains the value $150.00? Which row and column intersected at this cell? When you enterinformation into Access it will often be one cell at a time!

    Creating an Access Table

    When you create a table in Access you have to know what the table will store and what format that

    information will be in. For example if you wanted to store the product identification numbers involved ina sale, then you might label that column "ProductID" and specify that only numbers should be storedfor that column.

    1. With the Tables object tab selected, double-click the "Create table in Design view"

  • 7/30/2019 Database Mini Project

    4/14

    2. This will bring up the Table Design View

    3. There are three columns here that should be explained in detail:o Field Name: This is where you type the name for your column. A common practice is

    to make it one word and to use capitalization for multiple words squished into one(e.g. SaleNumber)

    o Data Type: This column is where you specify the type of data that will be stored. Ifyou are storing money then select Currency. The most common types of data are:Text, Number, Currency and Date/Time.

    o Description: Here you can type optional notes to remind yourself or provide useful

    information for others who might be viewing this file later.4. The first column in ourtbl_Sales example was Employee, so let's enter in Employee in the

    Field Name column and choose Text from the Data Type column. If click inside the Data Typecolumn you will see that it is actually a drop down select box with many options to choosefrom. Select the Text option.

    5. Enter the following information for our remaining three columns oftbl_Sales:

    o Field Name: Product, Data Type: Texto Field Name: Price, Data Type: Currency

    o Field Name: SaleNumber, Data Type: Number

    6. Before we are finished here, we need to make a Primary Key. A primary key is restriction thatwe place on a column stating that there can be no duplicate values in that column. Right-click in the SaleNumber row and choose Primary Keyfrom the pop-up menu.

  • 7/30/2019 Database Mini Project

    5/14

    7. We have finished our table's outline so click the X in the top right to close the design view(don't close Access, just the Design Window).

    This will also bring up a prompt to name your Access Table.

    8. Click yes and enter "tbl_Sales" for your table's name.

    The Next Step: Entering Data (Records)Creating an Access Database

    Now that we have completed the construction of our table we can finally begin to enter in our salesinformation. The next is the process of entering data into an Access table

    Access Records

    To begin entering records, double-click the table you want to add records to.

    1. Double-click the table tbl_Sales

  • 7/30/2019 Database Mini Project

    6/14

    2. This brings up the Table Window and you can see that our table contains no data, yet.

    3. five sales are as follows (note: Bob is currently the only "employee"):1. Sneaker - $402. Sneaker - $603. Slipper - $54. Heel - $125. Dress - $150

    4. Enter the information for first sale as follows:

    o Employee: Bob

    o Product: Sneakero Price: $40o SaleNumber: 1

    2. Enter the remaining four sales so that your table looks like:

    3. You're done entering the data! Close the table .

    Choosing a Table to Query

    Before you can create a query you have to navigate to the Query Tab in your Access database.Select Queries from the Objects Pane.

  • 7/30/2019 Database Mini Project

    7/14

    Although you could use the Wizard, we will use the process of creating an Access

    query with the "Design view".

    Double-click "create Query in Design view"

    1. Add the table tbl_Sales

    2. Your Query window should now have the tbl_Sales table added to it

    You have just completed the setup process for making a query. Every time you make a query you

    have to first choose which table(s) you want to select data from. Currently, our database only has onetable, so we don't have a lot of choices here.

    Now we can begin to create our custom Access query.

    Creating a Custom Query

  • 7/30/2019 Database Mini Project

    8/14

    If we want a query that will just return the list of items sold and for how much. To make this querywe are going to have specify the fields we want to see and ignore the others.

    Access lets you quickly select fields you want to see by a simple drag and drop method. For everfield that a table has there is an entry in the quick table viewer. Notice that the quick view oftbl_Salesdisplays the fields: *, Employee, Product, Price and SaleNumber. Note: The field * is a wildcard,meaning it will select all the fields if you choose *.

    We only want Product and Price, so let's start by dragging Product down from tbl_Sales to the firstcolumn. Notice that when you drop the Product field into the first column it populates two of the fieldsand checks the "Show" box:

    Drag and drop the Price field into the adjoining column and you should have something like:

    Close the Query window and save your file query as qry_ProdSales.

  • 7/30/2019 Database Mini Project

    9/14

    Running Your First Query!

    Double-click your newly created query and you should see something like this:

    Basic Query Review

    When you want to create a query that just uses a select few fields you can simply drag and drop

    these fields in design view. The next lesson will go into much more detail on creating custom queries,but remember this, you already have the knowledge to write queries in Access! Pretty impressive!

    Access Forms

    Access provides an easy way to enter data into your Access tables with forms. In Access youhave the ability to quickly make and customize these data entry forms to streamline the data inputprocess. Learning how to properly create an Access form will save you a great deal of time!

    Using our previous example, imagine that Bob, from Bob's Shoe Store, has recently hiredsomeone to enter all the sales data at the end of each business day. The only problem is this persondoes not know how to use Access, so Bob needs to make them a custom form in Access! This lesson

    will guide you through the process of creating a data input form in Access

    Creating an Access Form

    The form wizard is actually very useful .Let's create a simple data input form for the newemployee!

    1. Navigate to the Forms section in Access

  • 7/30/2019 Database Mini Project

    10/14

    2. Double-click "Create form by using wizard"

    3. We want all of the fields from tbl_Sales to be included in this form, so first select tbl_Salesfrom the drop down box "Tables/Queries"

    4. The single right arrow will add one selected field at a time, but we want all the fields. Theshortcut to add every field from a given table or query is to click the double arrow button. Dothat and click Next.

    5. Choose a Columnarlayout and press Next

    6. Choose any style and press Next (we chose "Sumi Painting")

    7. Change the form's title to frm_EmployeeEntry

    and click Finish

    Open up your form and check it out!

  • 7/30/2019 Database Mini Project

    11/14

    Entering Data Using Access Forms

    Now that the form has been created, we just needs to enter in the data. Open up

    frm_EmployeeEntry (easy!)

    1. At the bottom of the form is a set of arrows to navigate through the records. To get to the endof the existing records and begin entering data you need to click the arrow with an asterisk(*).

    2. Clicking that button will bring you to the first blank record, which would be the sixth in ourcase. You would then enter all the data for that record and click the right arrow to advance tothe next blank record. After all the new records have been entered, close the form and patyourself on the back.

    When you enter data into this form it will automatically add it to our existing tbl_Sales because we

    specified that table when we created our form.

    Access Reports

    Having all your data stored in Access is great for maintaining a database, but it isn't the best whenyou want to share the data or view it away from a computer. The solution to this problem is to createan Access report that will let you design a ready-to-print document of your desired databaseinformation.

  • 7/30/2019 Database Mini Project

    12/14

    Creating an Access Report

    Lets we wants a report to show the sales for each product, as well as the total sales for hiscompany.Let's explore how you would create this basic sales report in Access.

    1. Navigate to the Reports section in Access

    2. Double-click "Create report by using wizard"

    3. Select the query we created in the Access Query lesson qry_ProdSales and add both fieldsto the report.

    4. Click Next

    5. At the grouping step, add the Product field by clicking the right arrow and click Next

  • 7/30/2019 Database Mini Project

    13/14

    6. At the sorting step, select Price from the drop-down-box then click Summary Options ...

    7. Check the Sum box, so the report will include totals for the Price field and click OK

    and click Finish

    8. Click Next to advance to the layout options

    9. Choose a Stepped layout and a Portrait orientation, then click Next

    10.At the Style screen choose Bold and click Next

    11. Name the report rpt_Sales and click finish

    and click Finish

    Open up your report and check it out!

  • 7/30/2019 Database Mini Project

    14/14

    We can now print out this handy report and review sales in an easy-to-read fashion. If you wouldlike to make any changes to the report just right-click rpt_Sales and choose the "Design View" optionfrom the popup menu.