today’s goals yesterday we talked about different types of relationships in the ifri database, the...

Post on 29-Jan-2016

219 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Today’s Goals

• Yesterday we talked about different types of relationships in the IFRI database, the importance of keys, and how to interpret results of queries involving multiple tables

• Today we are going to talk about why there are 24 tables, how the tables are related to the paper forms, and how the tables are related to each other

1R. Kornak, AIT Training, July 2009

One-to-Many Relationship

1 Many

2

R. Kornak, AIT Training, July 2009

Many-to-Many Relationship

Many Species Many Trees

3R. Kornak, AIT Training, July 2009

IFRI Primary Keys• A primary key is a unique number

assigned to every record in a table

• The primary key of every IFRI table is named “ID”

4R. Kornak, AIT Training, July

2009

IFRI Foreign Keys• A foreign key specifies how records in one table

are related to records in another table• A foreign key displays the primary key of the

record it is related to in another table• The foreign keys of every IFRI table begin with

“FK_” followed by the name of the table they link with

5R. Kornak, AIT Training, July

2009

6

R. Kornak, AIT Training, July 2009

3 Types of IFRI Database Tables

7R. Kornak, AIT Training, July 2009

3 Types of Tables

• 1 Paper Form = 1 Database Table

• 1 Paper Form = Many Database Tables

• Tables necessary to link together forms that have many-to-many relationships– A forest can have many user groups– A user group can use many forests– The relationship between forests and user

groups is many to many

8R. Kornak, AIT Training, July 2009

Why Do Some Forms Have Multiple Tables?

9R. Kornak, AIT Training, July 2009

Repeating Information

• Database tables do not contain repetitive information

• Database tables only contain information about 1 topic and level of detail at a time– Information about sites and forests is stored in

two different tables

• You only see information repeated or about two different topics in the same table after you combine two or more tables in a query

10R. Kornak, AIT Training, July 2009

Translating Forms to Tables

• Most IFRI forms contain questions asking you to describe one object at a time– (a site, a settlement)

• Answers to all questions on the form apply to the whole object– All questions on the site form refer to the

entire site– All questions on the settlement form refer to

the entire settlement

11R. Kornak, AIT Training, July 2009

Translating Forms to Tables• IFRI forms in which all questions refer to the

same topic/level of detail have one table in the IFRI database.

12

Form Letter Form Name Number of Tables

Table Name

O Site Overview 1 OVERSITE

S Settlement 1 SETTLE

A Association 1 ASSOC

G Forest-User Group Relationship 1 GRPTOFOR

V Forest Governance 1 GOVERN

I (Part 1) Organization Inventory 1 ORGINVEN

I (Part 2) Interorganizational Arrangements 1 INTERORG

R. Kornak, AIT Training, July 2009

Forms with More than 1 Table

• Some forms contain questions about multiple levels of detail at the same time

• Why?...... Mostly to save paper and time!

• What if there were 1 paper form for every plant you measured or for every species in the forest?– You would have to write out the Top of Form

information several hundred times!

13R. Kornak, AIT Training, July 2009

Repeating Information

• What happens when an IFRI form contains questions about more than one topic or level of detail at the same time?

• You need to store the information about each topic/level of detail in a separate table

14R. Kornak, AIT Training, July 2009

Translating Forms to Tables

• Four IFRI forms contain questions asking you to describe more than one object at the same time– Forest, Plot, User Groups, and Product

Forms

• Answers to some questions on these forms DO NOT apply to the whole form

15R. Kornak, AIT Training, July 2009

• The Forest form contains questions about two levels of detail at the same time– Level 1: The entire forest

• Has this forest been divided into forest management units?

– Level 2: Individual species in the forest • e.g. Biological name, local name, whether they are

abundant, have they decreased over time, etc.• Answers to these questions do not apply to the

entire forest, only to the particular species

16

Example 1: Forest Form

R. Kornak, AIT Training, July 2009

• The Plot form contains questions referring to three levels of detail at the same time– Level 1: The entire plot:

• Is there evidence of livestock use within the forest plot?

– Level 2: Individual species:• What is the biological name; what is the local name?

– Level 3: Individual plants:• Plant type, DBH, height, % cover, stem count

• Answers to Level 2 and Level 3 questions do not apply to the entire plot 17

Example 2: Plot Form

R. Kornak, AIT Training, July 2009

Example 3 Plot Form

• Let’s look at the Plot form and try to find questions with species level and plant level detail

18R. Kornak, AIT Training, July 2009

Plot Form Sections B,C, D

19R. Kornak, AIT Training, July

2009

20R. Kornak, AIT Training, July 2009

Divide Tables by Topic

• Sections B, C, and D of the plot form contains questions about two different topics/levels of detail: species level and plant level

• We can store all of the species level information in one table because all three sections repeat the same questions– The table that contains species information

found on the plot form is called F_ORGAN21R. Kornak, AIT Training, July

2009

22R. Kornak, AIT Training, July 2009

23R. Kornak, AIT Training, July 2009

Plant Level Detail

• Let’s take a closer look at the questions about individual plants

• Notice that the questions about saplings, shrubs, and trees are the same– P_TYPE, P_DBH, P_HEIGHT

• While questions about ground cover are different– P_TYPE, P_PERCENT, P_STMCNT

24R. Kornak, AIT Training, July 2009

25R. Kornak, AIT Training, July

2009

26R. Kornak, AIT Training, July 2009

Divide Tables by Topic

• Section B of the Plot Form contains questions about groundcover

• We can store all of the groundcover level information in one table– The table that contains groundcover

information found on the plot form is called P_GCOVER

27R. Kornak, AIT Training, July 2009

28

Every row in the P_GCOVER table = 1 species

For herbaceous plants (H), only percent cover recordedFor Seedlings (S), only stem count recorded

R. Kornak, AIT Training, July 2009

Divide Tables by Topic

• Sections C & D contain questions about plant types other than groundcover

• We can store all of this information in one table because both sections repeat the same questions– The table that contains plant information other

than groundcover is called P_INFO

29R. Kornak, AIT Training, July 2009

Every row in the P_INFO table = 1 plant

30R. Kornak, AIT Training, July 2009

Queries with Plot Data

• If we want to create a query to study plot data, we will want to add several tables to our query

• Remember that the plot table itself does not specify the forest or site identification information

31R. Kornak, AIT Training, July 2009

Database Tables Related to Plot Information

32

Table Name Detail Level Importance:

OVERSITE Site Use to identify the site the plots belong to.

FOREST Forest Use to link to OVERSITE; identify forest that plots belong to

PLOT Plot Use to link to FOREST; Questions referring to the entire plot (P Form, Section A, E)

F_ORGAN Species Contains species information from 1m, 3m, and 10 m plots (P Form, Section B,C,D)

P_INFO Non-Groundcover

Contains plant type, DBH and height from 3m and 10 m plots (P Form, Section C,D)

P_GCOVER Groundcover Contains plant type, % cover and stem counts from 1 m plot (P Form, Section B)

R. Kornak, AIT Training, July 2009

Sample Query Designs

33

Every row in the P_INFO table = 1 tree

Every row in the P_GCOVER table = 1 species

R. Kornak, AIT Training, July 2009

Tips and Tricks

• When working with forms that have multiple database tables, it helps to think about each database table as its own form; one for each topic/level of detail

34R. Kornak, AIT Training, July 2009

Tips and Tricks

• For example, instead of a forest form and a plot form, we can think of these as five different forms

• 1. Forest Form

• 2. Plot Form– 3. Species Sub-Form– 4. Groundcover Plants Sub-Form– 5. Other Plants Sub-Form

35R. Kornak, AIT Training, July 2009

Table Types & Relationships

36R. Kornak, AIT Training, July 2009

Review

• We talked about: – Why most forms have only 1 database table– Why some forms have many database tables– Why linking tables are needed to link tables

with many-to-many relationships

• But how do these different types of tables relate to the Relationships Map?

• How does the Relationships Map relate to the paper forms?

37R. Kornak, AIT Training, July 2009

38

V

A

OS

I -1 I-2

G

Forms w/ 1 TableR. Kornak, AIT Training, July

2009

39

Linking Tables for Many-to-Many Relationships

R. Kornak, AIT Training, July 2009

40

P

F U

U

U

F

F

RR

P FP

P

Forms w/ Many Tables

R. Kornak, AIT Training, July 2009

Planning A Query

• Now that we know how to read the Relationships map, we can use it to figure out which tables we need to add to a query involving multiple tables

1.Locate all of the tables you are interested in on the relationships map

2.Notice how they link together.

3.Do you need to add any intermediate tables to your query?

41R. Kornak, AIT Training, July 2009

What We Know Now• How to open the relationships map in Access• How the paper forms relate to the relationships

map • How tables are related to each other by looking

at the relationships map• How to use the paper forms to figure out what

the column names and data mean within each table

• How to connect tables together using queries

42R. Kornak, AIT Training, July 2009

What’s Next?• With this knowledge we should be able to

pick questions from the IFRI forms and extract the data for only these questions from the database!

43R. Kornak, AIT Training, July 2009

1. Choose the questions you are interested in using the IFRI manual

2. Write down the form names and field names corresponding to your chosen information

3. Figure out which tables contain the data

4. Locate those tables on the IFRI relationships map

5. You may want to draw a diagram showing your chosen tables and the relationships between them before attempting to do the actual query

6. Add all of the tables to a new query

7. Choose the attributes from each table

8. Run the query

Steps to Design an Access Query

44R. Kornak, AIT Training, July 2009

Homework 1

• Which tables do you need to link the following tables in a query?– Oversite and Usergroup– Oversite and Interorg– Oversite to Plot– Forest to Association– Settlement to Usergroup

45R. Kornak, AIT Training, July 2009

Homework 2

• Which tables do you need to add to a query to find species information and DBH measurements of non-groundcover plants?

• Add them all to a query, select all fields from every table (* at the top of each table), and run your select query

46R. Kornak, AIT Training, July 2009

Homework 3

• Which table stores species information (e.g. “the species form”)?

• Which table stores groundcover measurements (“the groundcover form”)?

• Which table stores non-groundcover plant measurements (“the non-groundcover form”)?

47R. Kornak, AIT Training, July 2009

Homework 4

• If I’m interested in the site name, forest name, and plot latitude and longitude, do I need to add P_INFO, P_GCOVER, and F_ORGAN to my query?

• What does 1 row in the P_GCOVER represent?

• What does 1 row in the P_INFO table represent?

48R. Kornak, AIT Training, July 2009

top related