Presentation is loading. Please wait.

Presentation is loading. Please wait.

Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.

Similar presentations


Presentation on theme: "Access Module Implementing a Database with Microsoft Access A Great Module on Your CD."— Presentation transcript:

1 Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.

2 J-2 Management Information Systems for the Information Age Presentation Overview Implementing The Structure Of Your Employee Database Implementing The Structure Of Your Employee Database Defining Relationships Within Your Employee Database Defining Relationships Within Your Employee Database Entering Information Into Your Employee Database Entering Information Into Your Employee Database Creating A Simple Query Using One Relation Creating A Simple Query Using One Relation Creating An Advanced Query Using More Than One Relation Creating An Advanced Query Using More Than One Relation Generating A Report Generating A Report

3 J-3 Management Information Systems for the Information Age Introduction In Figure J.1 on the following slide, we’ve recreated the correct database structure from Extended Learning Module C. In Figure J.1 on the following slide, we’ve recreated the correct database structure from Extended Learning Module C. Revisit Module C if you need a refresher. Revisit Module C if you need a refresher.

4 J-4 Management Information Systems for the Information Age Introduction

5 J-5 Management Information Systems for the Information Age Implementing The Structure Of Your Employee Database Data dictionary - contains the logical structure for the information. Data dictionary - contains the logical structure for the information. To create a database using Microsoft Access, perform the following steps: To create a database using Microsoft Access, perform the following steps: 1. Start Microsoft Access. 2. 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. 3. Select a folder for the database and enter a file name (we’ll use Employee.mdb). 4. Click on Create.

6 J-6 Management Information Systems for the Information Age Implementing The Structure Of Your Employee Database Create a blank database by clicking on Blank Database.

7 J-7 Management Information Systems for the Information Age Implementing The Structure Of Your Employee Database Select a location and provide a database name.

8 J-8 Management Information Systems for the Information Age 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. 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. 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. Save that structure and repeat the process until you’ve created the structure for each relation in your database.

9 J-9 Management Information Systems for the Information Age Implementing The Structure Of Your Employee Database To define the structure of a relation, first select the Tables tab and then double-click on Create table in Design view.

10 J-10 Management Information Systems for the Information Age Implementing The Structure Of Your Employee Database Enter field names and data types here.

11 J-11 Management Information Systems for the Information Age Implementing The Employee Relation Structure To identify a primary key, place your cursor in the appropriate row and click on the key icon. The key icon will then appear to the left of the field name. This is the field properties for Employee ID, the primary key. Notice that it does not allow for duplicates.

12 J-12 Management Information Systems for the Information Age Implementing The Employee Relation Structure We entered three fields for the Employee relation – Employee ID, Name, and Department Num. We entered three fields for the Employee relation – Employee ID, Name, and Department Num.  Employee ID = Number  Name = Text  Department Num = Number

13 J-13 Management Information Systems for the Information Age Implementing The Employee Relation Structure We identified Employee ID as the primary key by placing a key symbol next to its field name. 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. You’ll perform this process for each primary key in each relation you create.

14 J-14 Management Information Systems for the Information Age 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. 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. You can then close the Table: Employee box.

15 J-15 Management Information Systems for the Information Age Implementing The Job Relation Structure Job Number is the primary key. This is the field properties for Job Name. We have set Allow Zero Length to No which means that you must enter something in this field.

16 J-16 Management Information Systems for the Information Age Implementing The Job Relation Structure We created the Job relation by using the Design view. 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. We identified Job Number as the primary key by placing the key icon beside its name in the field name list.

17 J-17 Management Information Systems for the Information Age Implementing The Job Relation Structure Let’s take a look at the Field Properties for Job Name. 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. 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).

18 J-18 Management Information Systems for the Information Age Implementing The Department Relation Structure This is the field properties for Department Name. Notice that we changed the Field Size from the default of 50 to 35. Always make sure text fields are large enough to handle any entry but not so large that you waste space.

19 J-19 Management Information Systems for the Information Age Implementing The Department Relation Structure We created the Department relation using the Design view. We created the Department relation using the Design view.  Department Num = Number  Department Name = Text We also specified that Department Num is the primary key by placing the key icon beside its name in the field name list. We also specified that Department Num is the primary key by placing the key icon beside its name in the field name list.

20 J-20 Management Information Systems for the Information Age Implementing The Department Relation Structure Let’s take a look at the Field Properties for Department Name. 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. 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. The field size for a text field can range from 0 to 255.

21 J-21 Management Information Systems for the Information Age Implementing The Job Assignment Relation Structure The Job Assignment relation is a composite (or intersection) relation, meaning that it will have two fields (Employee ID and Job Number) making up the primary key. To identify more than one filed as the primary key, highlight the appropriate fields and click on the key icon.

22 J-22 Management Information Systems for the Information Age Implementing The Job Assignment Relation Structure We entered all the field names We entered all the field names  Employee ID = Number  Job Number = Number  Hours = Number This particular relation is different from the rest because it has a composite primary key. This particular relation is different from the rest because it has a composite primary key.

23 J-23 Management Information Systems for the Information Age Implementing The Job Assignment Relation Structure Composite primary key - consists of the primary key fields from the two intersecting relations. Composite primary key - consists of the primary key fields from the two intersecting relations. We created the Job Assignment relation to eliminate the many-to-many relationship that existed between the Employee and Job relations. We created the Job Assignment relation to eliminate the many-to-many 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. 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.

24 J-24 Management Information Systems for the Information Age Defining Relationships 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. 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). Foreign key - a primary key of one file (relation) that appears in another file (relation).

25 J-25 Management Information Systems for the Information Age Defining Relationships Within Your Employee Database To define relationships in a database, you must first click on the Relationships button. When you first start this process, the Relationships palette will be blank. As you highlight each relation and click on the Add button in the Show Table box, the relations will appear on the palette.

26 J-26 Management Information Systems for the Information Age Defining Relationships Within Your Employee Database To create these relationships, you click on the Relationships button in the button bar. 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 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. 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. We then clicked on the Close button to make the Show Table box disappear.

27 J-27 Management Information Systems for the Information Age Defining Relationships Within Your Employee Database Enforce referential integrity by clicking here. Drag and drop primary keys onto foreign keys. This will create a one-to-many relationship. The “many” is denoted by the infinity symbol.

28 J-28 Management Information Systems for the Information Age Defining Relationships Within Your Employee Database Click on and drag each primary key and drop it onto its respective foreign key counterpart. 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. 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. In that box, you need to click on Enforce Referential Integrity and then Create.

29 J-29 Management Information Systems for the Information Age Entering Information Into Your Employee Database To enter information, you simply highlight the desired relation and click on Open. To enter information, you simply highlight the desired relation and click on Open.

30 J-30 Management Information Systems for the Information Age Entering Information Into Your Employee Database To enter information, highlight the appropriate relation and click on Open.

31 J-31 Management Information Systems for the Information Age Entering Information Into Your Employee Database When you begin entering information, your database will look very much like a spreadsheet with rows and columns.

32 J-32 Management Information Systems for the Information Age Creating a Simple Query Using One Relation Query-by-example (QBE) tool - helps you graphically design the answer to a question. 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. Suppose, for example, that we wanted to see a list of all employees by Employee ID and by Name.

33 J-33 Management Information Systems for the Information Age Creating a Simple Query Using One Relation To create a query, select the Queries tab and double-click on Create query in Design view.

34 J-34 Management Information Systems for the Information Age Creating a Simple Query Using One Relation This is the QBE grid. Then, select the appropriate relations by highlighting each of them individually and clicking on the Add button.

35 J-35 Management Information Systems for the Information Age Creating a Simple Query Using One Relation Since all the query information we need is in the Employee relation, it’s the only relation we added.

36 J-36 Management Information Systems for the Information Age Creating a Simple Query Using One Relation Next, we dragged and dropped Employee ID and Name from the Employee relation into the QBE grid.

37 J-37 Management Information Systems for the Information Age Creating a Simple Query Using One Relation After clicking on the exclamation point icon (Run), Access provided us with this result of our query.

38 J-38 Management Information Systems for the Information Age 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). 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. We often refer to this as a conditional query because it only returns results based on some condition.

39 J-39 Management Information Systems for the Information Age Creating a Simple Query Using One Relation To create a condition query, we added Department Num from the Employee relation and specified “=43” in the Criteria field.

40 J-40 Management Information Systems for the Information Age Creating a Simple Query Using One Relation The result of this query shows only employees in department 43.

41 J-41 Management Information Systems for the Information Age 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. 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. 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.

42 J-42 Management Information Systems for the Information Age Creating An Advanced Query Using More Than One Relation To show employees by ID, name, and department name, we added both the Employee and Department relations to the query.

43 J-43 Management Information Systems for the Information Age Creating An Advanced Query Using More Than One Relation We then dragged and dropped Employee ID and Name from the Employee relation and Department Name from the Department relation into the QBE grid.

44 J-44 Management Information Systems for the Information Age Creating An Advanced Query Using More Than One Relation The result of that query show employee information including Department Name, not Department Num.

45 J-45 Management Information Systems for the Information Age 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. 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.

46 J-46 Management Information Systems for the Information Age 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. To perform this query, we still only need two relations, this time Employee and Job Assignment. 1. Employee ID from Employee 2. Name from Employee 3. Department Num from Employee 4. Job Number from Job Assignment 5. Hours from Job Assignment

47 J-47 Management Information Systems for the Information Age Creating An Advanced Query Using More Than One Relation To show employees in department 43 who are assigned to job 23 for more than 4 hours, we added both the Employee and Job Assignment relations to this query.

48 J-48 Management Information Systems for the Information Age Creating An Advanced Query Using More Than One Relation We then dragged and dropped the necessary information into the QBE grid and specified the appropriate information in the Criteria fields.

49 J-49 Management Information Systems for the Information Age Creating An Advanced Query Using More Than One Relation The result shows only two employees.

50 J-50 Management Information Systems for the Information Age Generating A Report To create this report, follow these steps: To create this report, follow these steps: 1. Select the Reports tab. 2. Double click on Create report by using wizard. 3. Under Tables/Queries, select Table: Employee. 4. 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. 5. Under Tables/Queries, select Table: Department. 6. Under Available Fields, select Department Name and click on the greater than sign (>) to the right.

51 J-51 Management Information Systems for the Information Age Generating A Report 7. Click on Next>. 8. Click on Next>. (Allows you to choose ordering of information presentation.) 9. Click on Next>. (Allows you to specify grouping of information.) 10. Click on Next>. (Allows you to specify sorting of information.) 11. Click on Next>. (Allows you to select layout and page orientation). 12. Click on Next>. (Allows you to choose from among predefined reports styles). 13. Enter “Employee Report” (without the quote marks) for the title and click on Finish.

52 J-52 Management Information Systems for the Information Age Generating A Report To create a report, select the Reports tab and double-click on Create report by using wizard.

53 J-53 Management Information Systems for the Information Age Generating A Report Once you select a table (relation), you will see the list of fields in it. You add fields to a report by highlighting them and then clicking on the greater than sign (>) button.

54 J-54 Management Information Systems for the Information Age Generating A Report For our report, we included Employee ID and Name from the Employee relation.

55 J-55 Management Information Systems for the Information Age Generating A Report We then selected the Department relation to add more information to the report.

56 J-56 Management Information Systems for the Information Age Generating A Report From the Department relation we chose to add Department Name to the report.

57 J-57 Management Information Systems for the Information Age Generating A Report After accepting several default report options, we chose Employee Report as the name of the report.

58 J-58 Management Information Systems for the Information Age Generating A Report The report shows all employees by ID, name, and department name.


Download ppt "Access Module Implementing a Database with Microsoft Access A Great Module on Your CD."

Similar presentations


Ads by Google