HaagSM2 Implement SGBD Access 32

Embed Size (px)

Citation preview

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    1/32

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    2/32

    2 Skills Module 2

    In Chapter 3, we discussed the important role that databases play in an organization.We followed that with Extended Learning Module A, in which you learned how todesign the correct structure of a relational database. That Module included four pri-

    mary steps. They include:

    1. Defining entity classes and primary keys2. Defining relationships among entity classes3. Defining information (fields) for each relation (the term relation is often used to

    refer to a file while designing a database)4. Using a data definition language to create your database

    In Extended Learning Module A, you followed the process through the first threesteps above. In this Module, well take you through the fourth stepusing a data def-inition language to create your databaseby exploring the use of Microsoft Access,todays most popular personal database management system package (it comes as astandard part of Microsoft Office XP).

    Well also show you how to use some of Microsofts Access data manipulationsubsystem, including views, queries, and report generators.

    In Figure M2.1, weve recreated the correct database structure we defined inExtended Learning Module A. If its been awhile since you covered that Module, wesuggest you review it for the application of creating a database to track employees, towhich departments they are assigned, and which jobs they each perform.

    Introduction

    Cable Modemor

    DSL Modem

    Home Router(Firewall)

    WirelessAccess Point

    Hub orSwitch

    Other Connections

    are via Ethernet

    Printer Cable

    T11.5Mbps

    ISPRegional

    orNational

    Coaxial Cableor

    Phone Line

    The Internet

    Air

    Figure M2.1The Database Structure Well Be Implementing

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    3/32

    Implementing the Structure of Your Employee Database 3

    Note that this is a bonus Module. So you wont find the standard On Your Ownand Team Work projects integrated into the text here, nor will you find the standardend-of-Module support consisting of Summary, Short-Answer Questions, or Assign-ments and Exercises. We have simply provided this Module to add value to the text.

    As weve discussed with respect to databases, you cant simply start typing in infor-mation to create a database as you can when you create a document with word pro-cessing software or a workbook with spreadsheet software. You must first define thecorrect structure of the database (Extended Learning Module A), and then you mustcreate the structure of the database by creating its data dictionary before entering anyinformation. The data dictionary contains the logical structure for the information.Itincludes a description of each relation (also called a table or file) and each piece ofinformation in each relation.

    To create a database using Microsoft Access, perform the following steps (see Fig-ure M2.2):

    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 filename (well use Employee.mdb).4. Click on Create.

    Once youve performed the above steps, youll see the left screen in Figure M2.3.Youve now created a blank database with the name Employee.mdb. You are nowready to define the structure and information within each relation.

    Lets take a look at the left screen in Figure M2.3. Notice first that you can create

    relations (what Microsoft Access calls tables) in one of three waysin Design view,by using a wizard, and by simply entering information. They all achieve the sameresult. In this Module, well create the relations using the Design view.

    Notice also the tabs down the left side. They include Tables, Queries, Forms,Reports, Pages, Macros, and Modules. To work each specifically, you must first clickits respective tab. The default is Tables, and thats where well begin. Well also coverQueries and Reports, leaving Forms, Pages, Macros, and Modules up to you toexplore at a later time.

    To create a relation (table) using the Design view, make sure the Tables tab isselected and then double-click Create Table in Design View. You will then see thescreen on the right side of Figure M2.3. In that screen, you can see that MicrosoftAccess expects you to enter a name, data type, and description (the last is optional)

    for each field in a given relation. Once youve entered all that information (plussome more) for a given relation, you save that structure and repeat the process untilyouve created the structure for each relation in your database. Well do that forEmployee.mdb.

    Implementing the Structure ofYour Employee Database

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    4/32

    4 Skills Module 2

    Figure M2.2Creating a Blank Database

    Create a blank database by

    clicking on Blank Database.

    Select a location and provide a database name.

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    5/32

    Implementing the Structure of Your Employee Database 5

    IMPLEMENTING THE EMPLOYEE RELATION STRUCTURE

    To start, lets implement for the structure for the Employee relation within

    Employee.mbd. You might first notice that youre going to have a relation with thesame name as the overall database. Thats okay if it suits your purpose.In Figure M2.4, you can see that we have simply entered the three fields for the

    Employee relationEmployee ID,Name,andDepartment Num. ForEmployee ID, wechose the data type as Number; for Name, we chose the data type as Text; and for

    Department Num, we chose the data type as Number.You must choose a data type foreach field you enter. Once you enter a field name and press the tab key to move to thedata type column, youll find a pull down list of available data types.All you have to dois select the appropriate one.

    Figure M2.3The Start of Defining the Structure for Each Relation

    To define the structure of

    a relation, first select the

    Tables tab and then double-

    click on Create table in

    Design view.

    Enter field names and data types here.

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    6/32

    6 Skills Module 2

    You should also carefully note the Field Properties section across the bottom of thescreen in Figure M2.4. We currently have the cursor in the row forEmployee ID , so the

    Field Properties section displays the appropriate property information for that field.Notice that the Field Size is Integer, Decimal Places is 0, Required is Yes, and Indexedis Yes (No Duplicates). We specifically entered those properties forEmployee ID.Andthey all make sense. For example, Indexed must be Yes (No Duplicates) because

    Employee ID is the primary key for this relation. By setting this property to Yes (NoDuplicates), Access will not allow you (or anyone else) to enter employees with dupli-cate ID numbers. Thats an illustration of the enforcement of integrity constraints.

    Finally, notice that we further identifiedEmployee ID as the primary key by placinga key symbol next to its field name. To do this, simply position the cursor in the line ofthe primary key field and click on the key symbol in the button bar.Youll perform thisprocess for each primary key in each relation you create.

    Once youve created the structure the way you want it, you need to save it. To do

    so, click on the disk icon (Save As), enterEmployee as the table name, and click onOK. You can then close the Table: Employee box.

    IMPLEMENTING THE JOB RELATION STRUCTURE

    To implement the structures for the remaining relations,you simply follow the processgiven earlier. Lets now implement the structure for theJob relation. To create the Jobrelation using the Design view, make sure the Tables tab is selected and then double-click on Create Table in Design View.

    Figure M2.4Implementing the Employee Relation Structure

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    7/32

    Implementing the Structure of Your Employee Database 7

    In Figure M2.5,you can see that we entered the field names ofJob NumberandJobName. We also specified thatJob Numberis the primary key by placing the key iconbeside its name in the field name list.

    Lets take a look at the Field Properties for Job Name (we placed the cursor in theJob Name row to view the Field Properties). Since this is a text field, you have somenew Field Properties to consider. One of them is Allow Zero Length. If you leave this

    at Yes, youre essentially saying that anyone can enter a new job but not specify a name(i.e., blank). What you have to decide in every database environment is whether or nottext fields can be blank. Of course, if theyre key fields, you dont want to leave themblank. If theyre not key fields, you need to think about the necessity of having some-thing entered.

    For example, you might choose to allow a persons middle initial to be blankafterall, some people dont have a middle name. But, if you were creating a customer data-base to support a customer relationship management system,you would probably notwant the Customer Address field to be blank. Again, it all depends on the applicationyour database will support.

    To save this structure, we followed the same process as before. That is, we clickedon the disk icon (Save As), enteredJob as the table name, clicked on OK, and then

    closed the box.

    Figure M2.5Implementing theJob Relation Structure

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    8/32

    8 Skills Module 2

    IMPLEMENTING THE DEPARTMENTRELATION STRUCTURE

    Lets now implement the structure for theDepartmentrelation. To create theDepart-mentrelation using the Design view, make sure the Tables tab is selected and thendouble-click on Create Table in Design View.

    In Figure M2.6, you can see that we entered the field names ofDepartment NumandDepartment Name. We also specified thatDepartment Name is the primary key byplacing the key icon beside its name in the field name list.

    Lets take a look at the Field Properties for Department Name (we placed the cur-sor in the Department Name row to view the Field Properties). Since this is a textfield, the default size (Field Size) is 50 characters, which we changed to 35. The fieldsize for a text field can range from 0 to 255.Again, depending on the application yourdatabase will support, you need to consider the size of text fields. In our case, theknown department names are Non-profit, Residential, and Commercial.Each of thesehas a length much less than 35.

    You should be careful here not to make text field sizes too small. If we ever wantedto add a new department with the title GovernmentHousing and Urban Develop-

    ment (HUD), 35 characters would not be sufficient. On the other hand, you dontwant to set every text field to the maximum size limit (255)that would be a waste ofspace. Allow plenty of room when setting the size of text fields.

    Figure M2.6Implementing the DepartmentRelation Structure

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    9/32

    Implementing the Structure of Your Employee Database 9

    To save this structure, we followed the same process as before. That is, we clickedon the disk icon (Save As), enteredDepartmentas the table name, clicked on OK, andclosed the dialog box.

    IMPLEMENTING THE JOB ASSIGNMENTRELATION STRUCTURE

    Finally, we need to implement the structure for theJob Assignmentrelation. As youcan see in Figure M2.7, weve 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 pri-mary key, one that consists of the primary key fields from the two intersecting rela-tions. If you recall from Extended Learning Module A,we created theJob Assignment

    relation to eliminate the many-to-many relationship that existed between theEmployeeand theJob relation. TheJob Assignmentrelation has a primary key composed to twofieldsthe primary keyEmployee ID that originated in theEmployee relation and theprimary keyJob Numberthat originated in theJob relation.So theJob Assignmentpri-mary key is a composite primary key.

    To identify two fields aggregately that create a primary key, follow these steps:

    1. Define the basic structure of the relation by entering the field names and theirproperties.

    Figure M2.7Implementing theJob AssignmentRelation Structure

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    10/32

    10 Skills Module 2

    2. Move the pointer to the column immediately to the left of the first field of thecomposite primary key (the pointer will turn to an arrow pointing to the right).

    3. Click on that row and dont unclick.4. Drag the pointer so that the second field in the composite primary key is also

    highlighted.5. Unclick.

    6. Click on the key icon.Then the key icon will appear next to both fields signifying that the two combinedmake up a composite primary key.

    To save this structure, we followed the same process as before. That is, we clickedon the disk icon (Save As),enteredJob Assignmentas the table name, clicked on OK,and closed the dialog box.

    Believe it or not, up to this point all weve done is define the structure for each relationin our database. As you can see, its quite different from creating a word processingdocument or a workbook spreadsheet. And we still cant yet enter information intoour database. We have one final structural task to take care ofthat of defining how allthe relations relate to each other.

    If you recall from our discussions in Chapter 3 and Extended Learning Module A,you create relationships among the various relations by identifying foreign keys. Aforeign key is a primary key of one file (relation) that appears in another file (rela-tion). For our Employee database, we have the following primary keys appearing asforeign keys:

    Appears in Appears in

    Primary Key Relation: Foreign Key Relation:Employee ID Employee Employee ID Job AssignmentDepartment Num Department Department Num Employee

    Job Number Job Job Number Job Assignment

    Its vitally important that you tell your DBMS of the existence of foreign keys. Thatway, the DBMS can enforce integrity constraints. For example, when we specify that

    Employee ID is a foreign key (from theEmployee relation) in theJob Assignmentrela-tion, the DBMS will not allow us to enter anEmployee ID in theJob Assignmentrela-tion that does not appear as a primary key in the Employee relation. This makesbusiness senseyou cant have a job assignment for an employee that doesnt exist.

    To create these relationships, you click on the Relationships button in the button

    bar. Youll then see the screen shown in Figure M2.8. Notice that it lists all the rela-tions in our database. When you first start this process, the palette in the backgroundis blank. To identify the relationships, you must make each relation appear on thepalette. To do this, simply highlight each relation name and click on Add, which iswhat we did. We then clicked on the Close button to make the Show Table dialog boxdisappear.Now were ready to identify how all the relations relate to each other.

    To do this (and you must follow this process exactly), you click on and drag eachprimary key and drop it onto its respective foreign key counterpart.Once you drop theprimary key onto its respective foreign key counterpart, youll see the Edit Relation-

    Defining Relationships WithinYour Employee Database

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    11/32

    Defining Relationships Within Your Employee Database 11

    ships dialog box. In that box, you need to click on Enforce Referential Integrity andthen Create.

    When you drag and drop a primary key onto a foreign key, Microsoft Accessassumes that the relationship is one-to-many (1:M).That is, a primary key may appearmany times as a foreign key, and a foreign key must appear once and only once as a pri-mary key. If you perform the process in reverse (dragging and dropping the foreignkey onto a primary key), the relationship will be reversed (M:1), which is not at allwhat you want.

    You also need to turn on the enforcement of referential integrity. By doing so, yourDBMS will enforce the fact that when you enter a foreign key in a relation it mustmatch one of the primary keys in the other relation. Figure M2.9 shows the Edit Rela-tionships dialog box when we dragged and droppedJob Numberfrom theJob relationonto Job Numberin the Job Assignmentrelation. It also shows that we clicked onEnforce Referential Integrity.

    In Figure M2.9, you can see that we have already created the relationships betweenDepartmentand Employee and Employee and Job Assignment. In the first instance,Access shows a connecting line between theDepartmentandEmployee relations witha 1 near theDepartmentrelation and an infinity symbol near theEmployee relation.SoaDepartment Num in theDepartmentrelation can appear any number of times (infin-ity) in the Employee relation. Likewise, a Department Num that appears in the

    Employee relation can only appear once in theDepartmentrelation.When you have completed this process, click on the disk icon to save the relation-

    ships and then close the Relationships box.

    Figure M2.8The Start of Defining Relationships in a Database

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    12/32

    12 Skills Module 2

    Finally, were ready to begin entering information. Weve defined the structure foreach relation in the Employee database and weve defined the relationships among thevarious relations.

    To enter information, you simply highlight the desired relation and click on Open(see Figure M2.10). Well start by entering information in theDepartmentrelation.Does it matter in which relation you start entering information? It certainly does. Wecannot start by entering information in either the Employee or the Job Assignment

    relation. Why not? Because we chose to enforce referential integrity when we createdthe various relationships. So we cant enter information into theEmployee relation

    before entering information into the Departmentrelation because we must enter aDepartment Num in theEmployee relation. If aDepartment Num that we enter in theEmployee relation doesnt exist in the Department relation, Access will display anerror message and not allow us to continue.

    So, we must first enter information into theDepartmentrelation before enteringinformation into theEmployee relation. Likewise, we must also enter information intotheEmployee and Job relations before entering information into the Job Assignmentrelation. Clearly, this is very different from spreadsheet software.

    In the Figure M2.10, we have entered the information in theDepartmentrelation.After typing the appropriate information into each field, we used the Tab key to get to

    Figure M2.9Defining Relationships for the Employee Database

    Entering Information into Your

    Employee Database

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    13/32

    Entering Information into Your Employee Database 13

    Figure M2.10Entering Information in the DepartmentRelation

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    14/32

    14 Skills Module 2

    the next field or row. Once you enter all the information, click on the disk icon to savethe information and close the table (relation) box. You can then move on to entering

    information in the relations.Entering information in theJob andEmployee relations is very similar to what wejust did for theDepartmentrelation. So well skip showing you that and move on toentering information in theJob Assignmentrelation (the composite relation).

    In the first screen of Figure M2.11 you can see that weve entered all the informa-tion correctly in theJob Assignmentrelation except for the last record. For that record,we entered 8798 as the Employee ID, which is correct, and 8 as the Hours, which isalso correct. However, for the Job Number, we entered 22, which is not a validJob

    Numberbecause it does not exist as a primary key in theJob relation.An alert box appears informing us of the problem. When we click OK in that box,

    there appears the alert box shown in the next screen of Figure M2.11. It simply saysthat Access cannot save the record that has the error.If we choose to close the relation,

    Access will save the information without that particular record. If we choose not toclose the relation, Access will give us the opportunity to correct the information.

    As you can see,Access does enforce the integrity constraints (i.e., what it calls ref-erential integrity). We simply cannot enter aJob Numberin theJob Assignmentrela-tion that does not exist in theJob relation. This will hold true for entering any foreignkey in our database. For purposes of our presentation in this Module, we return to therelation and enter the correct information.

    Weve finally implemented the structure of our database and entered the necessaryinformation. Its now time to move on to building queries and reports. Incidentally, if youwant to view any of the database information,make changes to the information,and pos-sibly add new records,simply highlight the appropriate relation name and click on Open.

    Figure M2.10Entering Information in the DepartmentRelation (continued)

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    15/32

    Entering Information into Your Employee Database 15

    Figure M2.11Encountering an Integrity Error While Entering Information

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    16/32

    16 Skills Module 2

    The easiest way to create a query is to use a query-by-example tool. A 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 byName. All of that information is located in theEmployee relation, so this is a relativelysimple query requiring the use of only a single relation. Realize, of course, that ourdatabase is small and the query doesnt make much sense given you could easily opentheEmployee relation and see the desired information. But this is good way to intro-duce you to using a QBE tool. On the next several pages, well create more compli-cated queries.

    To create a simple query using one relation, perform the following steps (see FigureM2.12):

    1. Select the Queries tab.2. Double-click on Create Query in Design View. (You can also create a query

    using a wizardwell let you explore how to do that on your own.)3. In the Show Table dialog box, select the appropriate relation name, click on

    Add, and then close the Show Table dialog box.4. Drag and drop the fields into the QBE grid that you want in the query result.5. Click on the exclamation point icon (Run) in the button bar.

    As you can see in Figure M2.12, we followed that process by selecting theEmployeerelation, and dragging and droppingEmployee ID andName into the QBE grid. Oncewe clicked on the exclamation point icon, Access returned a list of employees by IDand name. Again, this is a very simple example.

    At this point we could save the query using a unique name such as Employees byName and ID. Then, if we ever wanted to run the query again, we wouldnt have to

    back through the steps above. We would, instead, see the unique name within theQueries tab and simply double-click on it to run it.

    Creating a Simple Query UsingOne Relation

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    17/32

    Creating a Simple Query Using One Relation 17

    Figure M2.12Creating a Simple Query Using One Relation

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    18/32

    18 Skills Module 2

    Figure M2.12Creating a Simple Query Using One Relation (continued)

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    19/32

    Creating a Simple Query Using One Relation 19

    As you can see, creating a simple query using one relation is in fact simple.So, letsmake it a bit more difficult. Lets assume that we wanted to see all employees by ID

    and name who are in the Residential department ( Department Num is 43). We oftenrefer to this as a conditional query because it only returns results based on some con-dition. This requires a couple of more steps than the previous query but is still veryeasy to perform.

    In Figure M2.13,you can see that again only selected theEmployee relation since itcontains all the information we need. However, this time we also dragged and dropped

    Department Num into the QBE grid. Within the QBE grid, we provided two impor-tant pieces of query information underDepartment Num.

    The first was to unselect the Show parameter. In doing so, were telling Access thatwe want to use Department Num as a part of the query but that we dont want it toshow in the query result. The second was to enter =43 in the Criteria parameter. Indoing so, were telling Access that we want to see only IDs and names of employees

    whoseDepartment Nums are equal to 43 (Residential). As you can see in the secondscreen of Figure M2.13, Access provided information for only three employees, all ofwhom work in the Residential department.

    Again, if we wanted to we could have saved this query using a unique name such asResidential Department Employees. It would then appear in our list within theQueries tab. If this were a real database for a very large organization, we would rec-ommend that you create this sort of query for each department.

    Figure M2.12Creating a Simple Query Using One Relation (continued)

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    20/32

    20 Skills Module 2

    Figure M2.13A Conditional Query Using One Relation

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    21/32

    Creating an Advanced Query Using More Than One Relation 21

    Lets move on to an even more complicated queryone that requires the use of two

    relations. Suppose we wanted a list of all employees by ID,name, and the departmentin which they work. However, instead of Department Num as the identifier for thedepartment, we would like to seeDepartment Name. That query will require the useof two relations because Employee ID and Name are in the Employee relation andDepartment Name is in theDepartmentrelation.

    To perform this query, we added both theEmployee and Departmentrelations fromthe Show Table dialog box (see Figure M2.14). Next, we dragged and droppedEmployee ID andName from theEmployee relation into the QBE grid.Then we draggedand droppedDepartment Name from theDepartmentrelation into the QBE grid. And,to tell you the truth, thats all you have to do. As you can see in the final screen of FigureM2.14, Access provided a list of all employees by name, ID, and name of department.

    Why did this work so easily? Because of the relationships we identified among the

    various relations,in this case theEmployee andDepartmentrelations. When executingthis query, Access took theDepartment Num of each employee, searched theDepart-ment relation until it found a match, and then used theDepartment Name in thematching record. As you can see, relationships via foreign keys are an integral part ofa database environment.

    Figure M2.14Creating an Advanced Query Using More Than One Relation

    Creating an Advanced QueryUsing More Than One Relation

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    22/32

    22 Skills Module 2

    Figure M2.14Creating an Advanced Query Using More Than One Relation (continued)

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    23/32

    Creating an Advanced Query Using More Than One Relation 23

    As a final query example, lets consider that we would like to see all the IDs andnames of employees who work in the Residential Department ( Department Num is43) who work more than four hours in Sales (Job Numberis 23) and how many hoursthey work in Sales.

    To perform this query, we still need only two relations, this timeEmployee andJobAssignment. As you can see in Figure M2.15, we added those from the Show Table

    dialog box. We then had to drag and drop five pieces of information into the QBE gridincluding:

    1. Employee ID fromEmployee2. Name fromEmployee3. Department Num fromEmployee4. Job NumberfromJob Assignment5. Hours fromJob Assignment

    Now, lets take some time to explore the QBE grid. Notice first that unselected theShow parameter for Department Num and Job Number. We needed those pieces ofinformation in order to perform the query but we didnt want them to show in the queryresult. Second, notice that theDepartment Num Criteria parameter is =43, which tells

    Access to find only those employees in the Residential department.Third, notice that theJob AssignmentCriteria parameter is =23, which tells Access to find only those employ-ees who have Sales jobs. Finally, notice that the Hours Criteria parameter is >4, whichtells Access to find only those employees with more than four hours of assignment.

    The result of our query is also shown in Figure M2.15. Although the query mayhave seemed difficult when written in narrative form, it was still relatively easy toimplement because of the foreign key relationships we identified earlier.

    Figure M2.15A Conditional Query Using More Than One Relation

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    24/32

    24 Skills Module 2

    Figure M2.15A Conditional Query Using More Than One Relation (continued)

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    25/32

    Generating a Report 25

    As we end our very brief tour of Microsoft Access, lets explore how to build a report.Well dispense with showing you how to build a simple report first and move insteadto a more complicated one that requires the use of two relations. Once you see how

    to build a somewhat complicated report, you can easily determine how to build asimple one.

    Building a report is a simple process, even for complicated reports, but you dohave to traverse many more screens. To create a report, well show you how to use awizard, and well leave creating a report in Design view up to your exploration. In ourreport, we would like to see a list of all employees by ID, name, and name of depart-ment. Again, this will require the use of two relations,Employee andDepartment. Tocreate this report, follow these steps (see Figure M2.16):

    1. Select the Reports tab (see panel A).2. Double-click on Create Report by Using Wizard (see panel B).3. Under Tables/Queries, select Table: Employee (see panel C).

    4. Under Available Fields, select Employee ID and click on the greater thansign (>) to the right; then select Name and click on the greater than sign (>)to the right (see panel D).

    5. Under Tables/Queries, select Table: Department (see panel E).6. Under Available Fields, select Department Name and click on the greater

    than sign (>) to the right (see panel E).7. Click on Next.8. Click on Next. (Allows you to choose ordering of information presentation.)

    (See panel F.)9. Click on Next. (Allows you to specify grouping of information.) (See panel G.)

    10. Click on Next. (Allows you to specify sorting of information.) (See panel H.)11. Click on Next. (Allows you to select layout and page orientation.) (See panel I.)

    12. Click on Next. (Allows you to choose from among predefined report styles.)(See panel I.)

    13. Enter Employee Report for the title and click on Finish. (See panels J, K,and L.)

    What youll then see is a screen representation of your report. It includes only theinformation we requested and in the style we chose in step 11.

    Unfortunately, we cant go in great detail concerning all the options you have foreach step. At your leisure,we recommend that back through the process and try someof the various options.

    Generating a Report

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    26/32

    26 Skills Module 2

    Figure M2.16Creating a Report Using More Than One Relation

    A

    B

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    27/32

    Generating a Report 27

    C

    D

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    28/32

    28 Skills Module 2

    E

    F

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    29/32

    Generating a Report 29

    G

    H

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    30/32

    30 Skills Module 2

    I

    J

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    31/32

    Generating a Report 31

    K

    L

  • 8/6/2019 HaagSM2 Implement SGBD Access 32

    32/32

    32 Skills Module 2

    Well, that ends our brief tour of Microsoft Access, a subject on which we could eas-ily have written several hundred pages.

    Its not really a difficult package to learn. The most difficult part happens beforeyou ever start Access: defining the correct structure of your database. We detailedthat process in Extended Learning Module A and we would definitely recommendyou study that Module if you want to become a designer and user of database appli-

    cations. Using is the easy partdesigning is the challenge.

    Key Terms and Concepts

    composite primary key, 9

    data dictionary, 3

    foreign key, 10

    query-by-example (QBE) tool, 16