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.
• We’re using the order entry design pattern here, but you might also use a model from one of our other exercises.
• Divide a stack of blank notecards 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.
• 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.
• 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:
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).
Copyright © 2002–2006, by Tom Jewett. Links to this site are welcome and encouraged. Individual copies may be printed for non-commercial classroom or personal use; however, this material may not be reposted to other web sites or newsgroups, or included in any printed or electronic publication, whether modified or not, without specific permission from the author.