Exploring Reference Card

Total Page:16

File Type:pdf, Size:1020Kb

Exploring Reference Card

Instructor Reference Card Access Chapter 2 Relational Databases and Multi-Table Queries

Concepts

At a Glance Summary

KEY CONCEPTS (blue) – most important concepts in this chapter

TIPS (red) – useful shortcuts and information for more productive use of Access

STICKY POINTS (green) – areas that might cause difficulty for students

TIP–A thoughtfully designed database is critical. The integrity of the design determines the credibility of the information extracted from the database. Database Design Guidelines 1. Include all of the necessary data 2. Design for the next 100 years 3. Design in compliance with Sarbanes Oxley 4. Design in compliance with PNPI Regulations 5. Store data in its smallest parts 6. Do not store calculated fields, which derive their value from formulas referring to one or more fields.

STICKY POINT–students may want to look up the exact details of the Sarbanes Oxley Act and PNPI regulations for more specific details.

TIP–recall that Access works from storage not memory. You need to name and save the blank database before you can create a table.

Creating Tables Methods used to create a table: you can design a table from scratch in design view; enter data directly into a table; use a wizard; or import table data from another database or application Points of focus when creating a table:  Field Names (should be descriptive of the data in the field) with no spaces in a multi- word fieldname. Use CamelCase notation, with uppercase letters to distinguish the letter of each new word, i.e., FirstName. Data type–the type of data that can be entered into a field (controls the operations that can be performed on that field)

TIP–Instead of selecting the field type from the drop down list of options, you can click in the data type column of the field’s row and type the first letter of the field type.

 Primary Key–a field (or combination of fields) that identifies a record as unique.  Foreign Key–a field in a table that exists as a primary key in another table.  Table Views–provide different ways to work with tables (datasheet, design, PivotChart)  Field Properties–the list of the characteristics and limitations of a field viewable in Design View. Some property options are: Field Size, Format and Caption. TIP–Use the Caption property to make field names that use CamelCase notation easier to read. Switching between Datasheet and Design Views–right click the apricot colored tab and select the desired view from the shortcut menu Multiple Table Databases–Similar items are grouped into tables and the tables are connected by links, called relations. STICKY POINT–explain a relationship between tables as an electronic string. The first end of the string is attached to the primary key and the other end is tied to a field in a different table. Referential integrity is a feature that ensures data and the relations between tables are reliable. Cascades–permits data changes to travel from one table to another (cascade delete and cascade update). TIP–make the connection between referential integrity and cascading deletes and updates. STICKY POINT–it is important to understand how cascading deletes work with one- to-many relationships. The cascading delete works when a record is deleted from the table on the “one” side of the relationship, but not when a record is deleted from the table on the “many” side of the relationship.

Index Property–a list that relates the field values to the records that contain the field value. All primary keys are automatically indexed. Additional table fields may also be indexed.

TIP–indexing is similar to an index in a textbook. It is used to find the location of a record in a database. Sharing Data with Excel–Data can be imported from and exported to Excel. Establishing Table Relationships: One-to-Many, One-to-One, Many–many Creating, Viewing and Deleting Relationships Use the Relationship window to manage relationships between tables: to create, edit or delete a relationship. Queries: Queries extract records from a database that match the specified criteria. STICKY POINT–when data is edited in a dataset the change will be made in the underlying table. Design view–contains a grid of columns (for field names) and rows (for criteria settings) TIP–display the uses of the Field row, Sort row, Show row, and Criteria rows. The wild cards ? and * as well as operands (like >, <,and >= )can be placed in the criteria to give it more flexibility. STICKY POINT–When criteria are in the same Criteria row of the grid, all criteria on that row must be met (AND operator). When they are not in the same row only one of the criteria must be met (OR operator). To run a query, click the Run command (the red exclamation point).

************************************************************* CONNECTIONS TO LEARNING – Practical Projects for the Student Access User Why is Access important to us??  Because we need to correlate multiple databases, such as managing the preferences of hotel “frequent visitors” (types of room, views, special needs, food and beverage.)  Because we have a large amount of data, such as coordinating activities for a university with multiple campuses and 24,000 students.  We need to exchange data, such as when government agencies share data (i.e. Social Security supplemental benefits with Medicaid patients.) Case Study Lecture Demonstration Document:

National Conference

Often, cases are geared towards business, which sometimes doesn’t engage students who major in other fields. In fact, all organizations, whether for-profit, educational, religious, or not-for-profit, have business components and require reliable information in order to make good decisions. This demonstration uses a college, rather than a business, as the organization. Here, students learn to import data from Excel into an Access table in an existing database. Many organizations use data from different systems that resides in different databases files across the organization, so the ability to import data from different sources into an Access database is an important feature of Access.

1. Copy the chap2_case_natconf.accdb file to your production folder. Name the copy chap2_case_natconf_solution.accdb. 2. Open the database and enable the content. 3. Examine the Relationships Window. 4. Import data from Excel.  Click the External Data tab. Select the Import Excel Spreadsheet command in the Import group. Import the source data into a new table in the current database.  Select the chap2_case_sessions.xlsx workbook and click OK to activate the Import Spreadsheet Wizard.  Select the Sessions worksheet from the list of worksheets in the workbook.  Click in the First Row Contains Column Headings check box to tell Access that column heads exist in the Excel file. ← NOTE: ← The SessionID field will be the primary key in the Sessions table.  Make note of the field types available for the SessionID field and select Long Integer as the field type.  Click the Choose my own primary key option. Make sure that the SessionID field is selected.  Specify the name for the table. Accept the default name, which is the name of the worksheet. 5. Establish a relationship between the Sessions table and the other tables in the database.  Click the Database Tools tab. Select the Relationships command from the Show/Hide group.  Click the Show Table icon and add the Sessions table.  Click the SessionID field in the Sessions table and drag the mouse to the SessionID field in the SessionSpeaker table 6. Replace the first record in the Speakers table with information about you.  Click anywhere in the first record to make it active.  Edit the fields in the record as appropriate.  Tab through all the fields or simply click on another record to save the changes to the database. 7. Create a new record in the Speakers table, with yourself as the speaker. Your area of expertise is Student Life.  View the table in Datasheet view and click the New Record icon to open a blank record.  Try to enter a value in the SpeakerID field. Point out the error message that appears in the Status bar. This error is generated because the value in this field is automatically generated.  Tab to the FirstName field and enter values for the rest of the fields. As soon as you begin entering data for the record, the value of the SpeakerID field is automatically populated. 8. Create a new session, titled Undergraduate Challenges. ← NOTE: ← Before entering this record, open the Sessions table in Design view. The field type of the SessionID field is Long Integer. Recall that when you imported the Sessions table from Excel, you set the field type for that field to Long Integer. AutoNumber was not an option.  View the table in Datasheet view and click the New Record icon to open a blank record.  Enter the name of the session in the SessionTitle field. Unlike the Speakers table, the SessionID is not automatically populated.  Try to move off the record without entering a value for the SessionID field. Access will give you a dialog box specifying that a primary key cannot contain a Null value. In other words, you must enter a value for the SessionID field. ← NOTE: Since Access uses a primary key to uniquely identify a record, it follows that primary keys cannot be null. Otherwise, how would Access identify the record? 9. Create a query that will show all sessions conducted by Davis, Kline, and you. The query should show the presenter’s name, the session title, and the room in which the session will be presented. ← NOTE: It may be helpful to look at the Relationships Window before creating the query. Although you don’t need any fields from the SessionSpeaker table, you need that table to establish a relationship between the Speakers and Sessions table.  Click the Create tab and select Query Design from the Other tab.  From the Show Table dialog box, select the Speakers, Sessions, and SessionSpeaker tables.  Select the FirstName, LastName, SessionTitle, and RoomID fields from the appropriate tables.  In the Query Grid, click the Criteria grid beneath the LastName field. Since you want the query to retrieve sessions conducted by either Davis, Kline, or the student, you will need to use an OR operator for the criteria. The string "Davis" Or "Kline" Or "YourName" will accomplish this. 10. The next step is to create a new table called Participants. ← NOTE: Before designing the table in Access, you should design it on paper. This makes a good discussion point with students.  Determine the fields you will need in this table. Specify field names, types, and any relevant properties. The fields will be similar, but not identical, to those in the Speakers table.  Determine the field or combination of fields that will make up the primary key.  Click the Create tab and select Table Design from the Tables group.  Enter the field names, types, and properties you have decided to include in the table.  Define your primary key by selecting the field(s) and selecting the Primary Key command in the Tools group.  Since the registration fee is $500, create a validation rule so that the only value the database will accept is $500.  Close the table and save it as Participants. ← NOTE: Although some students will likely suggest including a field identifying the sessions a participant attends, some discussion of one-to-many relationships would be helpful. A participant can attend more than one session. Stress that good database design dictates that the “many” side of a one-to- many relationship be stored in a different tables. Use the SpeakerSession table as a model. 11. Add a new row to the Participants table, adding yourself as a participant. 12. Capture a screenshot of the Relationships window and paste it into Word.  Click the Print Screen key on your computer. This will put the image on the screen into the Windows clipboard.  Open Word and use the Paste command to paste the image from the clipboard into the document.  Save the Word document as chap2_case_natconf_solution. 13. Compact and repair the file. Backup the database.  Select Manage from the Office menu. Select the Compact and Repair command.  Select Backup from the Office menu. Select the Back Up Database command.  Access creates a default name of chap2_case_natconf_solution, an underscore, and the current date. Replace the date so that the name of the backup is chap2_case_natconf_solution_backup.

Recommended publications