Exercise: building a database with notecards

This exercise is designed to increase your understanding of how relationships are represented by data, before you start actually entering data into tables. It is best done in groups of two or three people.

  1. We’re using the order entry design pattern here, but you might also use a model from one of our other exercises.
  2. Divide a stack of blank note cards (index cards) into three groups. On one group, write data that represents orders (one order per card). On the second group, write data that represents products (one product per card). On the third group, write data that represents order lines (one order line per card). Remember that you can’t make an order line without an order and a product (the parents). You might also make a stack of Customer cards, and show how one customer can place many orders.
  3. Use the format shown below. This is actually the UML notation for an object instance of a class; however, we are adding the primary and foreign keys from the relation scheme (just as you will do in the database). This may be a tedious bit of writing, but it will emphasize the fact that object instances and database rows both are actually functions that assign domain constants to attribute names.
  4. Use realistic data, but don’t just copy what we already have in the tables. Make enough cards to show at least a few orders that include multiple order lines, and a few items that were purchased on more than one order. Your cards should look like this:
    Sample sales database notecards for this exercise
    Sample sales database notecards for this exercise. Other views of this diagram: Large image - Description (text)
  5. When you are finished, arrange the cards so that they show how order lines and products are matched to the orders (or how orders and order lines are matched to products).