Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Skills Module 2 Implementing a Database with Microsoft Access Back Next M A P Skills Module 2 – Page 1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Main Map Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 2 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Introduction In Figure M2.1 on the following slide, we’ve recreated the correct database structure from Extended Learning Module A. Revisit Module A if you need a refresher. Back Next M A P Skills Module 2 – Page 3 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Introduction Figure M2.1 The Database Structure We’ll Be Implementing module page 2 Back Next M A P Skills Module 2 – Page 4 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing the structure of your employee database Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 5 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Structure Of Your Employee Database Data dictionary - contains the logical structure for the information. To create a database using Microsoft Access, perform the following steps: 1. 2. 3. 4. Start Microsoft Access. Select Blank Database on the right side of the screen or select File and New from the menu and then Blank Database on the right side of the screen. Select a folder for the database and enter a file name (we’ll use Employee.mdb). Click on Create. Back Next M A P Skills Module 2 – Page 6 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Structure Of Your Employee Database Figure M2.2 Creating a Blank Database (1) module page 4 Back Next M A P Skills Module 2 – Page 7 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Structure Of Your Employee Database Figure M2.2 Creating a Blank Database (2) module page 4 Back Next M A P Skills Module 2 – Page 8 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Structure Of Your Employee Database To create a relation (table) using the Design view, make sure the Tables tab is selected and then double-click on Create table in Design view. Enter a name, data type, and description (the last is optional) for each field in a given relation. Save that structure and repeat the process until you’ve created the structure for each relation in your database. Back Next M A P Skills Module 2 – Page 9 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Structure Of Your Employee Database Figure M2.3 The Start of Defining the Structure for Each Relation (1) module page 5 Back Next M A P Skills Module 2 – Page 10 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Structure Of Your Employee Database Figure M2.3 The Start of Defining the Structure for Each Relation (2) module page 5 Back Next M A P Skills Module 2 – Page 11 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Employee Relation Structure Figure M2.4 Implementing the Employee Relation Structure module page 6 Back Next M A P Skills Module 2 – Page 12 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Employee Relation Structure We entered the three fields for the Employee relation – Employee ID, Name, and Department Num. Employee ID = Number Name = Text Department Num = Number Back Next M A P Skills Module 2 – Page 13 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Employee Relation Structure We identified Employee ID as the primary key by placing a key symbol next to its field name. You’ll perform this process for each primary key in each relation you create. Back Next M A P Skills Module 2 – Page 14 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Employee Relation Structure To save the structure, click on the disk icon (Save As), enter Employee as the table name, and click on OK. You can then close the Table: Employee box. Back Next M A P Skills Module 2 – Page 15 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Job Relation Structure Figure M2.5 Implementing the Job Relation Structure module page 7 Back Next M A P Skills Module 2 – Page 16 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Job Relation Structure We created the Job relation by using the Design view. We identified Job Number as the primary key by placing the key icon beside its name in the field name list. Back Next M A P Skills Module 2 – Page 17 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Job Relation Structure Let’s take a look at the Field Properties for Job Name. Since this is a text field, you have some new Field Properties to consider. Allow Zero Length - if you leave this at Yes, you’re essentially saying that anyone can enter a new job but not specify a name (i.e., blank). Back Next M A P Skills Module 2 – Page 18 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Department Relation Structure Figure M2.6 Implementing the Department Relation Structure module page 8 Back Next M A P Skills Module 2 – Page 19 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Department Relation Structure We created the Department relation using the Design view. We entered the field names of Department Num and Department Name. We also specified that Department Num is the primary key by placing the key icon beside its name in the field name list. Back Next M A P Skills Module 2 – Page 20 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Department Relation Structure Let’s take a look at the Field Properties for Department Name. Since this is a text field, the default size (Field Size) is 50 characters, which we changed to 35. The field size for a text field can range from 0 to 255. Back Next M A P Skills Module 2 – Page 21 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Job Assignment Relation Structure Figure M2.7 Implementing the Job Assignment Relation Structure module page 11 Back Next M A P Skills Module 2 – Page 22 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Job Assignment Relation Structure We entered all the field names (Employee ID, Job Number, and Hours) and their types (all are Number). This particular relation is different from the rest because it has a composite primary key. Back Next M A P Skills Module 2 – Page 23 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Implementing The Job Assignment Relation Structure Composite primary key - consists of the primary key fields from the two intersecting relations. We created the Job Assignment relation to eliminate the many-tomany relationship that existed between the Employee and Job relations. The Job Assignment relation has a primary key composed of two fields – the primary key Employee ID that originated in the Employee relation and the primary key Job Number that originated in the Job relation. Back Next M A P Skills Module 2 – Page 24 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Defining relationships within your employee database Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 25 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Defining Relationship Within Your Employee Database We have one final structural task to take care of – that of defining how all the relations relate to each other. Foreign key - a primary key of one file (relation) that appears in another file (relation). Back Next M A P Skills Module 2 – Page 26 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Defining Relationship Within Your Employee Database Figure M2.8 The Start of Defining Relationships in a Database module page 11 Back Next M A P Skills Module 2 – Page 27 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Defining Relationship Within Your Employee Database To create these relationships, you click on the Relationships button in the button bar. To identify the relationships, you must make each relation appear on the palette. To do this, simply highlight each relation name and click on Add, which is what we did. We then clicked on the Close button to make the Show Table box disappear. Back Next M A P Skills Module 2 – Page 28 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Defining Relationship Within Your Employee Database Figure M2.9 The Start of Defining Relationships in a Database module page 11 Back Next M A P Skills Module 2 – Page 29 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Defining Relationship Within Your Employee Database Click on and drag each primary key and drop it onto its respective foreign key counterpart. Once you drop the primary key onto its respective foreign key counterpart, you’ll see the Edit Relationships box. In that box, you need to click on Enforce Referential Integrity and then Create. Back Next M A P Skills Module 2 – Page 30 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering information into your employee database Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 31 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database To enter information, you simply highlight the desired relation and click on Open. Back Next M A P Skills Module 2 – Page 32 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database Figure M2.10 TOP SCREEN Back Next M A P Skills Module 2 – Page 33 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database Figure M2.10 MIDDLE SCREEN Back Next M A P Skills Module 2 – Page 34 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database Figure M2.10 BOTTOM SCREEN ON NEXT PAGE Back Next M A P Skills Module 2 – Page 35 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database While entering data in your table you may encounter an integrity error This is possibly due to the relationship you have established such that you may have a problem with the primary key – foreign key relationship Back Next M A P Skills Module 2 – Page 36 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database Figure M2.11 top SCREEN Back Next M A P Skills Module 2 – Page 37 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Entering Information Into Your Employee Database Figure M2.11 BOTTOM SCREEN Back Next M A P Skills Module 2 – Page 38 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a simple query unsing one relation Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 39 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation Query-by-example (QBE) tool - helps you graphically design the answer to a question. Suppose, for example, that we wanted to see a list of all employees by Employee ID and by Name. Back Next M A P Skills Module 2 – Page 40 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation 1. Select the Queries tab. Figure M2.12a Back Next M A P Skills Module 2 – Page 41 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation 2. Double click on Create query in Design view. Figure M2.12b Back Next M A P Skills Module 2 – Page 42 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation 3. In the Show Table dialog box, select the appropriate relation name, click on Add, and then close the Show Table dialog box. Figure M2.12c Back Next M A P Skills Module 2 – Page 43 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation 4. Drag and drop the fields into the QBE grid that you want in the query result. Figure M2.12d Back Next M A P Skills Module 2 – Page 44 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation 5. Click on the exclamation point icon (Run) in the button bar. Figure M2.12e Back Next M A P Skills Module 2 – Page 45 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation Let’s assume that we wanted to see all employees by ID and name who are in the Residential department (Department Num is 43). We often refer to this as a conditional query because it only returns results based on some condition. Back Next M A P Skills Module 2 – Page 46 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation Figure M2.13a Back Next M A P Skills Module 2 – Page 47 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating a Simple Query Using One Relation Figure M2.13b Back Next M A P Skills Module 2 – Page 48 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating an advanced query using more than one relation Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 49 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Suppose we wanted a list of all employees by ID, name, and the department in which they work. However, instead of Department Num as the identifier for the department, we would like to see Department Name. That query will require the use of two relations because Employee ID and Name are in the Employee relation and Department Name is in the Department relation. Back Next M A P Skills Module 2 – Page 50 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Figure M2.14a Back Next M A P Skills Module 2 – Page 51 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Figure M2.14b Back Next M A P Skills Module 2 – Page 52 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Figure M2.14c Back Next M A P Skills Module 2 – Page 53 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation As a final query example, let’s consider that we would like to see all The IDs and names of employees who work in the Residential Department (Department Num is 43) who work more than four (4) hours in Sales (Job Number is 23) and how many hours they work in Sales. Back Next M A P Skills Module 2 – Page 54 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation To perform this query, we still only need two relations, this time Employee and Job Assignment. 1. 2. 3. 4. 5. Employee ID from Employee Name from Employee Department Num from Employee Job Number from Job Assignment Hours from Job Assignment Back Next M A P Skills Module 2 – Page 55 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Insert figure M2-15a Back Next M A P Skills Module 2 – Page 56 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Insert figure M2-15b Back Next M A P Skills Module 2 – Page 57 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating An Advanced Query Using More Than One Relation Insert figure M2-15c Back Next M A P Skills Module 2 – Page 58 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating a report Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Back Next M A P Skills Module 2 – Page 59 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report To create this report, follow these steps: 1. 2. 3. 4. 5. 6. Select the Reports tab. Double click on Create report by using wizard. Under Tables/Queries, select Table: Employee. Under Available Fields, select Employee ID and click on the greater than sign (>) to the right and select Name and click on the greater than sign (>) to the right. Under Tables/Queries, select Table: Department. Under Available Fields, select Department Name and click on the greater than sign (>) to the right. Back Next M A P Skills Module 2 – Page 60 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report 7. 8. 9. 10. 11. 12. 13. Click on Next>. Click on Next>. (Allows you to choose ordering of information presentation.) Click on Next>. (Allows you to specify grouping of information.) Click on Next>. (Allows you to specify sorting of information.) Click on Next>. (Allows you to select layout and page orientation). Click on Next>. (Allows you to choose from among predefined reports styles). Enter “Employee Report” (without the quote marks) for the title and click on Finish. Back Next M A P Skills Module 2 – Page 61 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16a Back Next M A P Skills Module 2 – Page 62 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16b Back Next M A P Skills Module 2 – Page 63 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16c Back Next M A P Skills Module 2 – Page 64 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16D Back Next M A P Skills Module 2 – Page 65 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16E Back Next M A P Skills Module 2 – Page 66 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16F Back Next M A P Skills Module 2 – Page 67 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16G Back Next M A P Skills Module 2 – Page 68 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16H Back Next M A P Skills Module 2 – Page 69 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16I Back Next M A P Skills Module 2 – Page 70 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16J Back Next M A P Skills Module 2 – Page 71 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16K Back Next M A P Skills Module 2 – Page 72 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Generating A Report Insert Figure M2.16L Back Next M A P Skills Module 2 – Page 73 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved