Home Home | About Us | Sitemap | Contact  
  • Info For
  • Professionals
  • Students
  • Educators
  • Media
  • Search
    Powered By Google

The Leading Edge


R. Jason Weiss
Development Dimensions International


This issues edition of the Leading Edge was submitted by guest writer Robert J. Townsend. 

Data Warehousing With Microsoft Access

Robert J. Townsend
California State UniversityFullerton

The term data warehousing conjures several images; 1,000 terabyte hard drives housed within multiple servers, network administrators ensuring the server remains functional, and a group of hackers looking for a backdoor to steal data. Although this imagery has an element of truth, it can lead to the perception that a database is too cumbersome or exorbitant for typical data storage needs. After all, we need a programmer to build and maintain a database, right? Let me introduce Microsoft Access, the data warehousing tool that needs to be added to every I-O psychologists desktop. 

Access was developed for people who work with data, who do not have (or want) the programming experience necessary to build an SQL database but need to work with data more flexibly than Excel will allow. Access offers several advantages over Excel when data entry is required. Although an Excel form is an excellent tool if one user will be entering data, Access allows several users to enter data simultaneously. An Access database can be set to open to a specific form and not allow users the ability to view or make changes to the layout of the table. Forms in Access will allow linking to data located in another table, resulting in quicker data entry and higher data integrity. For example, one table can contain survey data from multiple sites, and the second table can contain site information. Access forms will allow the user to select the site from a drop down box and will automatically link the survey data to the site information. Through linking tables, Access will allow users to enter more than Excels maximum 256 fields of data. An Access database will take a little more time and thought to set up than an Excel file but can offer a much higher return on investment depending on the needs of the user.

Databases and forms have been frequent topics within this column. Past issues of TIP have described the structure of databases (Weiss & Worst, 2002) and the related security issues (Worst & Weiss, 2003). More recently, Weiss (2004) wrote of using forms in Excel to enter data. This article will be an extension of these three articles with a specific applicationhow to create a database in Microsoft Access with a form for multiple users to enter data. I will illustrate the advantages and the ease of getting started with Access in this issues Leading Edge column. I will show how to easily create multiple tables (similar to worksheets in Excel), define the relationships between the tables, and create an electronic form that can be used by multiple users at the same time to enter data into a single database.

Create the Database Tables

Our example database will be a survey that past readers should find familiar; the Weiss Circus Clown Selection Test, Revised (WCCST-R). In past columns, the fictional survey was used to collect data from clowns applying for jobs. In this column, we have (fictionally) mailed surveys to multiple clown-placement agencies across the nation so that we can start creating a larger norm base for the test. Each agency will receive 25 surveys labeled 1 to 25. Our database will need two tables; one table will contain contact information for the agency, and the second table will contain data from the returned surveys.

Open Access, select New Blank Database, choose where the database will reside, and Save. Make sure that Tables is highlighted and select New. Select Design View and click Okay. You will now be presented with the screen from Exhibit 1. 

Exhibit 1. Agency Table Design View

Exhibit 1 is a snapshot from the Table Design View. You will notice several key fields in this view. The Field Name is the name given to a variable. When exported to another program, the contents of this field will be exported as the name of the variable. A field must also have the Data Type declared. This task is performed automatically in Excel but needs to be manually entered in Access. Several Data Types are available, including Text, Number, Date/Time, and so forth. A distinction should be made between the Memo Data Type and the Text Data Type. A Text Data Type can hold up to 255 characters, while the Memo Data Type can hold 65,000 characters and include special characters like the enter and tab key. The OLE Object Data Type is a nifty field that can be used to store actual files, such as Word, Excel, PDF, or JPEG files, into rows of data. Our Clown table will use this field to upload electronic rsums that clowns submit with their surveys. The Description field allows the user to write a short comment about the field. Each field also has several Field Properties associated with it depending on the Data Type selected. For example, an AutoNumber Data Type will not have the same Field Properties as the Text Data Type. Field Properties allow the user to declare the specifications of the field, such as how many characters will be allowed in a field (Field Size) or the value of a field when a record is created (Default Value). For the most part, the Field Properties default settings are perfect for most databases. The required yes/no setting can come in pretty handy on any field. In addition, the Input Mask can be used to predetermine how Text Data Types can be entered. For example, a Phone Number Input Mask can be applied so that all characters in the field are formatted like (555) 555-1234. Input Masks can only be added to the Text Data Type and the Date/Time Data Type. 

Each field in the table will need a Field Name and a Data Type; the Description is optional. The first and most important field in the table is the Agency ID (A_ID). Referred to as the Primary Key, this will be a unique number that identifies each agency and will be used to link an agency record with a clown record. Select the AutoNumber Data Type to automatically generate this number each time a new record is entered. Add the remaining Field Names and Data Types as seen in Exhibit 1. 

Next the Primary Key needs to be created. As mentioned earlier, this is the field that will be used to link one table to another. Duplicate entries and null values are not allowed in a field that is a Primary Key because duplicates defeat the purpose of being able to flexibly create tables of data. A Text Data Type (like a name) can be used as a Primary Key, but a Number Data Type is recommended. Highlight the Primary Key field and go to Edit | Primary Key or click the small icon in the toolbar that looks like a key. After all fields have been named and had properties declared, save the table as Agency. You can now alternate between the design view and the datasheet view by clicking View | Design View or by clicking the small icon in the toolbar that looks like a spreadsheet.

Now its time to create a table that will house the survey data collected from the clowns. This process should be followed exactly like creating the Agency table. Enter the Field Name and Data Types exactly like Exhibit 2. Our survey has 10 questions, so the Field Names should span from Q1 to Q10. 

Exhibit 2. Clown Table Design View

The Clown table will have two primary keys: Agency ID (A_ID) and Survey ID (S_ID). In this case, the combination of values entered in these two fields will be unique and cannot be duplicated in other rows. To clarify, using our survey as an example, each agency was given 25 surveys numbered 1 to 25. An agency with a unique A_ID number of 3 cannot have multiple clowns fill out survey #1. However, agencies 1, 2, 3, & 4 can all have clowns fill out survey #1. To create multiple Primary Keys, go to View | Indexes (if applicable, delete any indexes showing). In the field Index Name, supply a name for the Primary Key and select A_ID as the Field Name. Under Index Properties, select Primary: Yes; this is your first primary key. Go to the next record, do not supply a name, and select S_ID as the field name; this is your second Primary Key. Close the Indexes: Clown box and save the table as Clown.

Define the Relationship Between the Tables

It is now time to define the relationships between the tables. Weiss and Worst (2002) do a great job of describing the different types of relationships that can exist between tables. In summary, there can be two types of relationships. In a one-to-one relationship, one value from one field in Table A (a field with no duplicates) matches one value from one field in Table B (another field with no duplicates). In a one-to-many relationship, one value from one field in Table A (a field with no duplicates) has several matches in one field from Table B (a field that allows duplicates). 

In our clown database, the A_ID field in the Agency table (a field that does not allow duplicates) will link to the A_ID field in the Clown table (a field that allows duplicates). Therefore, our Agency to Clown link will be a one-to-many relationship. To define this relationship, go to Tools | Relationships. Next, go to Relationships | Show Table and add both the Agency and Clown table. Select the A_ID field from the Agency Table and drag it onto the A_ID field in the Clown table (note: when creating your own database, Data Types must match between linked fields). An Edit Relationships Box will appear; click Join Type. In our agency table, we will enter every agency name in the table; however, not every agency will respond. Therefore, there may be some cases when records in the Agency table will not have matching records in the Clown table. Selecting Include ALL records from Agency and only those records from Clown where the joined fields are equal will allow the database to show all Agency records even when they do not have a matching Clown record. Select OK, then Create, and your Relationships box should match Exhibit 3. 

Exhibit 3. Relationship Between Agency Table and Clown Table


Create the Data Entry Form

A form can be used for a variety of purposes, including data entry, viewing data, and performing certain tasks. Fields from tables in the database are combined with text and images from the form to create a dynamic and customized interface with the database. Adding fields, text, and images are as simple as drag and drop. In our example, a form will be used to enter survey data into the Clown table. 

Heres how well create our form. Go to the opening screen for the database and highlight Forms under Objects. Click New, select Design View, choose the Clown table, and select OK. This is the design view for your new form. Make sure the Toolbox (View | Toolbox) and the Field List (View | List) is showing. The Toolbox contains several buttons that can be customized for use in the form. You can view the names of the buttons by placing the cursor over the Toolbox. The Field List contains all the fields in the Clown table. 

Begin by resizing the table to approximately 4 inches in width by 4 inches in height. Click on the Label icon in the Toolbox and draw a label on the top of the form from one side to the other. Type Clown Survey Data Entry and press enter. While the label is selected, use the upper toolbar to adjust the font size to 20 and text alignment to center. The first data entry field should allow the users to choose an agency. This drop-down Combo Box will need to grab the names of the agencies from the Agency Table. Highlight the Control Wizards, select Combo Box, and use the cursor to draw a small box on the form. Select I want the combo box to look up the values in a table or query and press next. Select the Agency table and press next. The combo box should be filled with the names of the agencies, so select Name and press next. Select Hide Column Key and press next. When users select a name from the combo box, the corresponding A_ID number from the Agency table needs to be stored in the A_ID field in the clown table. Select Store that value in this field, select A_ID, and select next. Name the label Agency Name and press Finish. The remaining data entry fields can be added by dragging the fields from the Field List onto the Form. Drop, place, and size the fields so that your form matches Exhibit 4. Once finished, save the form as Clown Info.

Exhibit 4. Clown Form Design View

The database needs to be tweaked so that data entry can happen quickly. Users can use the tab key to toggle between fields when entering survey data. Go to View | Tab Order to adjust tab order. Certain form properties need to be changed. Go to View | Properties, select Form from the drop down box, and select the All tab. These changes need to be made: set Data Entry to Yes, Record Selectors to No, Navigation Buttons to No, Dividing Lines to No, and Auto Center to Yes. Next, the database needs to have certain features disabled at startup. In our example, the database will be formatted so that it will open to the Clown Info form and disable all views for the user. This will prevent any mishaps or accidental deletion of records when an admin or a temp is entering survey data. Go to Tools | Startup, name the application title Enter Clown Survey Data, select Clown Info as the display form, and uncheck all boxes. Note: The next time the database is opened, it will display the Clown Info form without any Access toolbars. Hold down the shift button while double clicking the database to open in the regular view. 

The database is complete and ready to be moved to its permanent location. A database should house all data and should not be saved on more than one computer. The ideal situation is a centrally located PC that everyone can access. There are several configurations that can be used. The database can be placed on a central server that everyone can access. Multiple users would be able to enter data from different PCs simultaneously without a problem. In addition, if the server has an IP address, users could potentially use Access to enter data from home or from different offices. The database can also be placed on a PC that is networked to other computers without a central server. Multiple users would be able to access the database via My Network Places and enter data simultaneously. If only one PC is available, then only one person can enter data at a time.

Multiple users are able to use the form and enter data at the same time. In Excel, multiple users can enter data on a shared workbook but with several limitations, including the inability to enter hyperlinks or embed files. Excel files could be copied and pasted onto several machines to overcome this obstacle, but this would result in multiple files that would need to be merged to view the final data set. In Access, the database is located in a central location without the limitations of Excel. Entering data is simple. Users locate the database on the network or online. Upon opening, users can increase data entry speed by tabbing between the fields. To insert a rsum, the user will need to left click and select Insert Object. After the final field is filled, the user can press tab to go to the top of the form and begin entering a new record. 

This article has covered how to develop an Access database that can be used to enter and store data. However, the abilities of Access are far reaching. Data sets can be easily appended, deleted, merged, and updated. Access can be used to query and analyze data, generate on-the-fly reports on the analysis of data, and automate several tasks with the push of one button. I-O psychologists can easily work this functionality into research and practice. Weve all had the experience of searching for the folder within a folder within a folder that contains the data file related to a certain project. An Access database can serve as the single storage location for data collected from multiple instruments. Several versions of a data set can reside in this database. The limit to the amount of storage in an Access database is 2 gigabytes. Finally, I-O psychologists who work with data sets will appreciate the level of data security. Multiple temps (or undergraduate assistants) can be used to enter data without the concern of destroying sensitive data. Access is a powerful program that has much to offer. Please consult the additional resources section for more information. 

References

     Weiss, R. J. (2004, April). Leading edge: Using Excel forms. TIP: The Industrial-Organizational Psychologist, 41, 6169.
     Weiss, R. J. & Worst, J. (2002, October). Leading edge: Databases and I-O. TIP: The Industrial Organizational Psychologist, 40, 4956. 
     Worst, J. & Weiss, R. J. (2003, January). Leading edge: Database security and I-O. TIP: The Industrial-Organizational Psychologist, 40, 9397.

Additional Resources

The file used as the example in this article is available for download at http://www.robertjtownsend.com/publications.html. Please feel free to use this file as an example of how to create forms in Access. 

Please consult these books for more information on Microsoft Access:

Prague, C. & Irwin, M. (2001). Access 2002 Bible. New York: Wiley Publishing, Inc.

Viescas, J. L. (1999). Running Microsoft Access 2000. Microsoft Press. 

Questions or Comments?

If you have questions or comments about this article, please dont hesitate to e-mail me at inbox@robertjtownsend.com

 

April 2005 Table of Contents | TIP Home | SIOP Home