Using a Database

3.4 Using a Database

PREREQUISITE SKILLS/CONCEPTS

  • Record data on spreadsheets.
  • Organize data.
  • Use computer applications to examine data.

MATH BACKGROUND

A database is an organized set of factual information, or data. On a computer database this data is displayed as rectangular arrays.

Learn about the Math

Marianne coaches a girls’ softball team. She is using a database to store data about the players. She is looking at each player’s record to determine who is the best batter on the team.

database an organized set of information, often stored on a computer
record all the data about one item in the database; for example, one player (see orange row)
A database. The column headings are as follows: player number, last name, first name, phone number, position, times at bat, singles, doubles, triples, home runs. A record comprises the entries along a row, and a field consists of the entries in a column.

How can you use this database to find the best batter on the team?

  1. In a database, each field should serve a particular purpose, or have a reason for being included. What fields are shown above?

    ANSWER player number, last name, first name, phone number, position, times at bat, singles, doubles, triples, home runs

  2. A field can be a text field, a numeric field, a date field, or a memo field. Which type of field is each field in Marianne’s database?

    ANSWER text fields: last name, first name, position; numeric fields: player number, phone number, times at bat, singles, doubles, triples, home runs; date and memo fields: none

  3. Which field has Marianne used to sort the information above?

    ANSWER player number

    sort order information from greatest (or first) to least (or last); a database can be sorted by fields
  4. State the name that would appear first if you sorted the information in the database by each of the following.
    1. last name

      ANSWER Ali, Olivia

    2. first name

      ANSWER Anita Kong

    3. times at bat

      ANSWER Marcie Barrett (sorted in ascending order) or Pat Miller (sorted in descending order)

    4. phone number

      ANSWER Olivia Ali

  5. Marianne wants her best batter to be up third. How should she sort the database to find her best batter? Which player should she choose to bat third? Why might someone disagree?

    ANSWER She can sort based on greatest number of home runs, etc., Marianne will create a new field called “Batting average”. To do so, she needs to add the number of each player’s hits, divide this sum by the number of times the player has been at bat, and round the dividend to three places. As Pat Miller has a batting average of 0.840, she is the best batter. Her sister Trina, however, has an equal record as to home runs and triples and thus could also be chosen to bat third.

Reflecting

    1. Why would it not make sense for Marianne to rank her players by sorting the database using “Phone #”? Why is it useful to have this field anyway?

      ANSWER For example, players’ phone numbers are not indicative of their skill. The field is useful because Marianne will likely need to call the players.

    2. What other fields might a coach find useful? Explain.

      ANSWER For example, batting average and on-base percentage would be useful because batting line-ups are often based on this data. Whether a batter bats right or left-handed or can switch hit would also be useful.

  1. Marianne’s database contains information for only 9 players. Suppose it is changed to hold the data for all 15 players on the team. How might the revised database be used?

    ANSWER For example, it might be used to decide specific player line-ups against specific teams, or who to send in as a replacement pitcher, hitter, or runner.

  2. Who might have information about you or your family in a database? Give two examples.

    ANSWER For example, schools, various government agencies, health care professionals, employers

Work with the Math

Example 1: Sorting a database for letter frequencies

Indira decides to create a database for the information about the QWERTY keyboard and letter frequencies in lesson 3.1. Her database is shown. How can Indira sort her database to find out how many of the 10 most frequent letters are typed with the left hand?

A database. The column headings are as follows: letter, frequency in 1000 letters, row on keyboard, fingers used to type, hand used to type. The record for all the letters is entered.

Indira’s Solution

A database. The column headings are as follows: letter, frequency in 1000 letters, row on keyboard, fingers used to type, hand used to type. The top 10 entries are E, T, N, R, I, O, A, S, D and H. The letters are typed with the left hand except for N, I, O and H.

I sorted by the field “Frequency in 1000 letters.” I used the “sort” button and chose “descending” instead of “ascending” to list the letters from greatest to least frequent. I see the letters in descending order of frequency. Six of these letters are typed with the left hand.

Example 2: Sorting a school database

Mrs. Cooper, the school secretary, keeps a student information database on the school computer. Part of her database is shown.

A database.

Visual description

Visual Description

The column headings are as follows: student number, last name, first name, grade, room, home phone number, emergency contact, allergy, bus number. The entries are as follows. Row 1. Student number, 4158. Last name, Brown. First name, James. Grade, 7. Room, 214. Home phone number, 555 4411. Emergency contact, 555 2214. Allergy, none. Bus number, 441. Row 2. Student number, 5532. Last name, Adams. First name, Melissa. Grade, 7. Room, 214. Home phone number, 555 3392. Emergency contact, 555 9932. Allergy, peanut. Bus number, 414. Row 3. Student number, 3327. Last name, Adams. First name, Mark. Grade, 5. Room, 116. Home phone number, 555 3392. Emergency contact, 555 9932. Allergy, none. Bus number, 414. Row 4. Student number, 7225. Last name, Chu. First name, Frank. Grade, 6. Room, 116. Home phone number, 555 6248. Emergency contact, 555 8454. Allergy, penicillin. Bus number, walk. Row 5. Student number, 4233. Last name, Goring. First name, Mandy. Grade, 8. Room, 222. Home phone number, 555 7302. Emergency contact, 555 9745. Allergy, peanut. Bus number, walk. Row 6. Student number, 3329. Last name, Hardy. First name, Melissa. Grade, 8. Room, 214. Home phone number, 555 8780. Emergency contact, 555 4123. Allergy, none. Bus number, 441. Row 7. Student number, 7764. Last name, Yan. First name, Ye. Grade, 5. Room, 116. Home phone number, 555 9834. Emergency contact, 555 3381. Allergy, none. Bus number, 414. Row 8. Student number, 7833. Last name, Walker. First name, Mark. Grade, 6. Room, 118. Home phone number, 555 4487. Emergency contact, 555 2526. Allergy, nuts. Bus number, 414.

Mrs. Cooper wants to create a school phone directory of these eight names alphabetically by last name and then first name. If she sorts the database, which name will be third?

Mrs. Cooper’s Solution

A database, sorted by last name and first name.

Visual description

Visual Description

The column headings are as follows: student number, last name, first name, grade, room, home phone number, emergency contact, allergy, bus number. The last and first names, sorted alphabetically, are as follows. Adams, Mark. Adams, Melissa. Brown, James. Chu, Frank. Goring, Mandy. Hardy, Melissa. Walker, Mark. Yan, Ye.

First I sorted the last names alphabetically. Then I sorted the first names alphabetically.

Now the third name is James Brown.

C. Checking

  1. State which name will appear last if Mrs. Cooper sorts the database by the following information.
    1. grade, from highest to lowest

      ANSWER Yan, Ye; The lowest grade is 5, and two students are in grade 5: Mark Adams and Ye Yan. Since Yan comes after Adams alphabetically, Ye Yan will be the last name on the list.

    2. grade, from lowest to highest

      ANSWER Hardy, Melissa; The highest grade is 8, and two students are in grade 8: Mandy Goring and Melissa Hardy. Since Hardy comes after Goring alphabetically, Melissa Hardy will be the last name on the list.

    3. room number, from greatest to least

      ANSWER Yan, Ye; The least room number is room 116, and three of the students are in room 116. Since, of the three, Ye Yan has the last name alphabetically, she will be the last name listed.

    4. room number, from least to greatest

      ANSWER Goring, Mandy; The greatest room number is room 222, and Mandy Goring is the only student in that room.

  2. Which kind of field (text, numeric, date, or memo) should you choose if you want to sort the following data?
    1. e-mail addresses

      ANSWER text; e-mail addresses are written in text

    2. math marks

      ANSWER numeric; math marks are numeric

    3. shoe sizes

      ANSWER numeric; shoe sizes are numeric

    4. comments about student effort

      ANSWER memo; comments about student effort are messages, or memos

    5. days when deliveries are expected

      ANSWER date; days are dates

    6. ingredients in cereal

      ANSWER text; ingredients are listed in text

B. Practising

  1. So far, Anthony has input the following data in a database of all the videos his family owns.
    A database. The column headings are as follows: code, title, studio, year released, running time in minutes, and notes.

    Visual description

    Visual Description

    The row entries are as follows. Row 1. 1, Grease, paramount, 1977, 110, has interviews with the stars. Row 2. 2, Shrek, dreamworks, 2001, 93, features Mike Myers doing Shrek’s voice. Row 3. 3, The little mermaid, Disney, 1989, 83, was my first video. Row 4. 4, Casper, Universal, 1995, 101, produced by Steven Spielberg. Row 5. 5, Agent Cody Banks, M G M studios, 2003, 103, stars Frankie Muniz.

    1. Identify which fields are numeric, text, date, or memo.

      ANSWER numeric: Code, Year Released, Running time (min); text: Title, Studio; date: (none); memo: Notes

    2. If Anthony sorts his database by “Year released” (from most recent to least recent), which movie will be third?

      ANSWER Agent Cody Banks 2003, Shrek 2001, Casper 1995, The Little Mermaid 1989, Grease 1977
      The third year is 1995. Casper is the third movie.

  2. The following database lists information about different countries in the world.
    A database.

    Visual description

    Visual Description

    The column headings are as follows: country, continent, area in square kilometers, population in millions, and population density in people per square kilometer. The row entries are as follows. Row 1: Australia, Australia, 7687000, 19.4, 2.7. Row 2: Brazil, South America, 8512000, 174.4, 20.6. Row 3: Canada, North America, 9976000, 31.6, 3.5. Row 4: China, Asia, 9597000, 1273, 137.7. Row 5: Congo, Africa, 342000, 53.6, 23.7. Row 6: Iceland, Europe, 103000, 0.3, 2.7. Row 7: Jamaica, North America, 11000, 2.7, 248.2. Row 8, Niger, Africa, 1267000, 10.4, 8.2. Row 9: Singapore, Asia, 620, 4.3, 6893.4. Row 10: United States of America, North America, 9373000, 278.1, 30.7.

    1. How is the data sorted in this database?

      ANSWER by Country

    2. If you sorted this database by population, which country would appear first?

      ANSWER China: 1273; U.S.A.: 278.1; Brazil: 174.4; Congo: 53.6; Canada: 31.6; Australia: 19.4; Niger: 10.4; Singapore: 4.3; Jamaica: 2.7; Iceland: 0.3
      China would be first on the list.

    3. If Iceland appeared last, which field would you have used to sort?

      ANSWER Population; Iceland is last on the list in the above list sorted by population.

    4. If Singapore appeared first, which field would you have used to sort?

      ANSWER Population density; Singapore’s population density of 6693.4 people/square km is the greatest in the list.

    5. If you sorted this database in increasing order by area, what would be the first five countries?

      ANSWER
      Singapore: 620; Jamaica: 11 000; Iceland: 103 000; Congo: 342 000; Niger: 1 267 000; Australia: 7 687 000; Brazil: 8 512 000; U.S.A.: 9 373 000; China: 9 597 000; Canada: 9 976 000
      The first five countries would be Singapore, Jamaica, Iceland, Congo, and Niger.

  3. As a school fundraiser, students are selling chocolates. This is a sample order form.
    A form titled The A B C Chocolate Bar Company order form.

    Visual description

    Visual Description

    At the top is a row with 3 columns for student's name, homeroom, and phone number. The table below has 5 columns: customer's name, chocolate almond bars at 2 dollars and 50 cents each, chocolate mint wafers at one dollar and 50 cents each, milk chocolate megabars at 2 dollars each and sales summary. Each column except the first, is further divided into 2 parts, quantity and cost. The first row reads as follows. Customer's name, Jennifer Jones. Chocolate almond bars at $.250 each. Quantity, 4. Cost, $10. Chocolate mint wafers at $1.50 each. Quantity, 2. Cost, $3. Milk chocolate megabars at $2.00. Quantity, 4. Cost, $8. Sales summary. Quantity, 10. Cost, $21.

    1. How is an order form the same as a record in a database?

      ANSWER As in a database, an order form has several fields, space for records (customer orders in this case), and room for entries in the records under each field.

    2. Explain how you could use the information in the order form to create a database for the school.

      ANSWER The headings in the order form could be the names of the fields in a data base, and each customer order could be a record in the database.

    3. Use a computer to create a sample database from the order form.

      ANSWER
      For example,

      A form titled The A B C Chocolate Bar Company order form.

      Visual description

      Visual Description

      At the top is a row with 3 columns for student's name, homeroom, and phone number. The table below has 5 columns: customer's name, chocolate almond bars at 2 dollars and 50 cents each, chocolate mint wafers at one dollar and 50 cents each, milk chocolate megabars at 2 dollars each and sales summary. Each column except the first, is further divided into 2 parts, quantity and cost. The row entries are as follows. Row 1. Customer's name, Jennifer Jones. Chocolate almond bars at $.250 each. Quantity, 4. Cost, $10. Chocolate mint wafers at $1.50 each. Quantity, 2. Cost, $3. Milk chocolate megabars at $2.00. Quantity, 4. Cost, $8. Sales summary. Quantity, 10. Cost, $21. Row 2. Customer's name, Omar Ali. Chocolate almond bars at $.250 each. Quantity, 6. Cost, $15. Chocolate mint wafers at $1.50 each. Quantity, 4. Cost, $6. Milk chocolate megabars at $2.00. Quantity, 2. Cost, $4. Sales summary. Quantity, 12. Cost, $25. Row 3. Customer's name, Keshia Green. Chocolate almond bars at $.250 each. Quantity, 2. Cost, $5. Chocolate mint wafers at $1.50 each. Quantity, 3. Cost, $4.50. Milk chocolate megabars at $2.00. Quantity, 1. Cost, $2. Sales summary. Quantity, 6. Cost, $11.50.

  4. Not all databases are computerized. You use a database every time you look up a phone number in the phone book. What databases would you use to find the following information?
    1. what to order in a restaurant

      ANSWER a menu

    2. how to spell a word

      ANSWER a dictionary

    3. tomorrow’s weather conditions

      ANSWER the weather section of a newspaper

    4. an alternate word for “good”

      ANSWER a thesaurus

    5. the area of a country

      ANSWER an atlas or an encyclopedia

  5. Katya wants to get some information for a project on probability. She goes to the school library and uses the library’s database to find the following information.
    A database. The column headings are as follows: call number, author, title, publisher, date published, status, description, and category.

    Visual description

    Visual Description

    The row entries are as follows. Row 1. Call number, 519.2 Cus. Author, Cushman, Jean. Title, Do you wanna bet? Publisher, Clarion Books. Date published, 1991. Status, checked out. Description, story about two boys who find out that the most ordinary events are dependent on probability. Category, probability. Row 2. Call number, 123.302 Rip. Author, Ripley, Robert. Title, Book of Chance. Publisher, Collins. Date published, 1982. Status, checked in. Description, thousands of extraordinary facts about winners and losers. Category, probability. Row 3. Call number, 519.2 Hol. Author, Holland, Bart. Title, What are the Chances? Publisher, John Hopkins University Library. Date published, 2002. Status, checked in. Description, voodoo deaths, office gossip, and other adventures of probability. Category, probability.

    Identify which field Katya should use for each situation.
    1. if she wants the most recent book

      ANSWER Date published; arranges the entries to list the most recently published first

    2. before she looks for the book on the shelves

      ANSWER Status; lets Katya know if the book is available

    3. when she is trying to find the book on the shelves

      ANSWER Call #; indicates where to find the book

    4. if she wants to find other books by the same author

      ANSWER Author; lists together all books in the list by the same author

C. Extending

  1. Describe how each worker might use a database.
    1. a family doctor

      ANSWER for example, patient’s names, health card numbers, phone numbers, addresses, history of health

    2. a veterinarian

      ANSWER for example, find pet information: pet’s cared for, pet owner, pet health history, operations performed

    3. a police officer

      ANSWER for example, criminal history including date of offence, details of offence,

    4. a real estate agent

      ANSWER for example, find homes for sale, by listing of price, location, contact number