![]() |
|
|
|
Anthy 497G – GIS In Archaeology Lab Exercise 10
Step 1: Create a new Access database Step 2: Create a new table for Phase information Repeating the previous step add a field Phase_Name as a Text data type with field size 10 (currently the longest field name is Nativas with 7 characters), and a description “Archaeological Phase Name”. The final step is assigning the field Phase_ID to be the primary key field for the table. Highlight the Phase_ID field definition, then click the Primary Key icon from the toolbar. This will place a key icon next to the Phase_ID field definition. Select File->Save As from the main menu and change the table name from Table 1 to Phases. Then close the table design. A new table called Phases has been added to the database. Step 3: Data enter Phase information Try to enter Phase_ID values with more than 2 characters, Phase_Name values with more than 10 characters. Try to enter Start_Date or End_Date values that include text characters or that are negative numbers. Finally try to enter in two rows of data with the same Phase_ID value (e.g. 02 for both the Cruz II and Ramo phases). Notice that the database will not let you do any of these things. By applying appropriate constraint conditions and a primary key we have been able to ensure that our database will successfully reject certain obvious data entry errors.
Step 4: Create Ceramic Types data table Field Name Data Type Field Size Description Set the Type_ID field to be the primary key field for the table. Step 5: Create Foreign Key Constraint Once you have added the Cer_Types and the Phases tables, Click the Close button to close the Show Table window. The relationships window now contains windows for both the Cer_Types and Phases tables. The entry for each lists the fields in each table (notice that in both cases the Primary Key field is displayed in Bold face. The Foreign Key relationship we want to set up links the Phase field in the Cer_Types table to the Phase_ID field in the Phases table. To make the relationship click and hold down the left mouse button on the Phase listing in the Cer_Types table, then still holding down the mouse button drag the mouse to the Phase_ID listing in the Phases table. Release the mouse button and the Edit Relationships window will be displayed. Click the check boxes next to the Enforce Referential Integrity, Cascase Update Related Fields, and Cascade Delete Related Records entries. Click the Create button to create the relationship. Notice that there is now a line connecting these two fields. This indicates that the foreign key constraint has been created.
Click the Close icon to close the Relationships window and return to the Tables listing in Access, respond Yes when you are asked if you want to save the changes to the layout of the Relationships. Step 6: Data enter Ceramic Types information Why did we enter the value of 01 in the Phase field? We entered 01 because if you look at the Phases table you will see that the Phase_ID for the Cruz I phase, is 01. The next listed ceramic type entry in our original flat file is for Iglesia Polychrome dating to the Nativas phase. What phase code should we enter in for this row of data? As you can see the only way to figure out what phase code to enter is by looking back at the Phases data table. This is a difficult, and potentially error prone methodology. It would be better if we could select the phase by it’s name and have the computer enter in the phase code for us. Step 7: Set up a Combobox for Phase data entry Highlight the Text Box entry and from the drop down list change the control to be a Combo Box. Notice that a new set of options is displayed. Change the Combo Box options to be Row Source: Phases, Bound Column: 1, Column Count: 4, Column Widths: 0;1;0;0. Your screen should match the list below: The reason we specified Phases as the Row Source is because the table Phases contains the list of all the potential phases we have to choose from. Step 8: Continue Ceramic Types data entry What’s interesting is that although Access is showing us the list of phase names, behind the scenes it is actually storing the Phase_ID value in the Phase field. That’s to say when we select Nativas from the list, behind the scenes Access is entering a value of 05 in the data table. Continue doing data entry to enter the rest of the ceramic types from the flat file. Notice that if a ceramic type is listed more than once we only need to enter in the first occurrence, after that any other rows would be redundant. Once you are finished your table should look like this: Step 9: Create Sites and Ceramics Tables Sites For the Elevation field delete out the default value of 0 and set the Validation Rule to be >=0 And <=5500 so that the field will only accept values from 0 to 5500 meters ASL. Also set the field Site_ID to be the primary key for the table. Ceramics Set the Cer_ID field to be the Primary Key. For the Type field set the field properties to be a Combo Box, Row Source: Cer_Types, Bound Column: 1, Column Count: 3, Column Widths 0;1;0. After creating the tables go into the Relationships view (as outlined in step 5). Use the Show Table tool to add the Sites and Ceramics tables to the window. Set up the relationships so that the field Type in the Ceramics table links to the Type_ID field in the Cer_Types table. Also link the Site_ID field in the Ceramics table to link to the field Site_ID in the Sites table. In both cases make sure that you checked the 3 check boxes in the Edit Relationships window. Step 10: Data Entry for Sites and Ceramics Tables We could enter all the rest of the data in these tables but there’s a fairly high probability that we would make some errors in linking the Ceramics entries to their appropriate Site_ID values. Step 11: Create a Data Entry Form On the database change the Objects to Forms Double click the Create form by using wizard selection to bring up the form wizard. Change the entry under Tables/Queries to be Sites. Notice that the list of available fields now changes to be the fields in the Sites table (Site_ID, Site_Name, and Elev). Highlight the Site_ID field and then click the > button to move the entry from being under the Available Fields to the Selected Fields. Repeat this procedure to move Site_Name and Elev to the Selected Fields list Change the Tables/Queries entry to be Ceramics and only move the Type field to the Selected Fields list (leave the Cer_ID and Site_ID fields under the Available Fields list). Finally select the Phases table and move the Phase_Name, Start_Date and End_Date fields to the Selected Fields list. Click the Next > button to move to the next window. Through the next series of windows just leave the default selected values and click the Next > buttons to move through the windows. On the final window click the Finish button to complete the form design. Along there way there were numerous ways we could have modified the look of this final form but this gives a very serviceable form with a minimum of effort. Notice that the form currently contains the information for the first site. Note how the site information is contained in the upper half of the form and the ceramic data is in the bottom half. At the bottom of the window there are two Record selector bars: On the bottom one of these two click the Right arrow icon to bring up a blank form where we can enter the information for the 2nd site. Looking back at the original flat file the 2nd site is the Zotinco site at an elevation of 1230, but with no associated ceramic information. Enter in a site ID of MIA-002 and the name and elevation information data but leave the ceramic portion of the form empty. Click the right arrow icon again to bring up a new form and this time enter Site_ID: MIA-003, Elev: 785 (leave the Name field blank because there was no name supplied in the original file). Next go to the first line in the Ceramics grid and select ceramic type Iglesia Polychrome from the list. Notice how the form automatically fills in the associated Phase information for us. This is part of the power of a good relational database design, the database management system is doing a lot of the work for us. In the 2nd row of the ceramics grid select Hard Thin Gray as the ceramic type, again Access fills in the rest of the phase information for us. Use the preceding techniques to enter the information for the remaining 3 sites (Guerrero, Rayal I, and Rayal II). When you are finished close the form (Access automatically saved your changes while you did the data entry. Return to the Tables object and open up the Ceramics table. Notice how the data entry form automatically entered the linking site information for us. We entered the Site_ID only once on the form but it updated the values in both the Sites and the Ceramics table. Once again the use of a relational database design makes the overall structure somewhat more complicated than a flat file but we have a greater amount of control and can use built in tools of the database management system to perform a variety of functions for us. Close Ceramics table and exit Access to end this lab exercise.
|