Welcome to my Access Blog
Access Developer Tools
FMS Developer Tools are arguably the most comprehensive set of tools for Access, SQL Server, and .NET developers.
Access Sites and Pages
My Blog List
-
-
COVID-19 Supplies Tracking Database4 years ago
-
-
Over Worked?7 years ago
-
Stay connected wherever work takes you8 years ago
-
-
-
-
-
Access Support Sites
About Me
Introduction to VBA Debugging
Microsoft MVP Walter Niesz has put together a nice FAQ (Frequently Asked Question) article over at UtterAccess.com to introduce new Access programmers to de-bugging VBA Code. The article illustrates three basic debugging techniques that should be in every VBA programmer’s toolkit. If you are new to VBA or Access have a look at Debugging Techniques. While you are at UtterAccess.com have a look around at the thousands of opportunities to learn from other’s questions and to find answers to your own questions. (disclaimer: as a forum administrator at UtterAccess I enthusiastically support the forum which is, “without doubt is the only source for all of your Microsoft Access help needs...and more! ")
Access 2010 Navigation
Check out this Access Team Blog article in which Wouter Steenbergen describes new navigation features in Access 2010 in detail
John R. Durant's WebLog : Why VBA Still Makes Sense
This article, John R. Durant's WebLog : Why VBA Still Makes Sense , presents a solid case for why VBA is the ‘next level’ when it comes to application development in Access and other members of the Office suite. John provides an excellent of VBA since its early days to the present and on into Office 2010 including his perspective on the ‘fit’ between .NET and VBA. John R. Durant's WebLog : Why VBA Still Makes Sense is definitely a worthwhile read.
Breaking News – Major Step Forward in Access 2010
Ryan McMinn and Clint Covington demonstrate the most significant new Access feature being introduced in the 2010 version View the latest Office Team Blog article and click the link to their video.
We Are Moving
to www.officetipsandmethods.com
A little over a year ago I started two blogs, Argee's Office Help Blog and Argee's Access Blog. As the titles suggest, the first focuses on entire Microsoft Office applications except for Microsoft Access. The second is aimed strictly at Microsoft Access related topics. I found a number of free blog hosts and started my first OfficeHelp, a Windows Live Site. After publishing a few articles there, I wanted to be able to separate Access oriented articles from those related to the rest of the Office suite. Windows Live blogs are great for personal/social blogs but I couldn’t find a way to classify or categorize articles with more that a single category/tag for each article.
Visiting a few blogs by my Access colleagues led me to consider the Blogger site which is hosted by Google. I decided to locate my Access site there. Each article can have multiple tags. That makes it easier to specifically classify articles so that a reader can find specific topics more quickly.
Recently, I have come to realize that I really wanted an even more sophisticated classification system than what is possible on the Blogger site. Part of this need stems from the significant change that Microsoft introduced into user interfaces with Office 2010. These changes were particularly significant in Access, my main area of interest. A little Internet searching led me to the WordPress publishing platform.
Will WordPress solve my classification problem? It certainly seems so, and then some. I found that I can set up custom categories and sub-categories. That means that I can flag an article as relating to Access generally, to Access 2007, specifically, and that the article is part of a tutorial. I can also tag each article with one or more tags that will aid in subject oriented searching. Best of all, I found I can include a category search capability in a side bar that is always there at the top of the blog page.
WordPress may not be the last word in meeting my blogging needs but so far I like the look and feel. Now it’s time to get back to writing. For the time being I will mirror articles that I publish at OfficeTipsAndMethods on my OfficeHelp and Access blogs so if you have subscribed to one or both of those feeds you will still be notified of new articles in those blogs. But if you want a “one feed serves all” feed, visit
and subscribe to the rss feed there.
Coding Standards Survey – The Importance of Comments in VBA Code
At the end of August, a discussion at my home away from home, UtterAccess.com piqued my interest in the topic of how experienced Access developers viewed the importance of commenting their VBA Code. I decided to conduct a brief survey of two groups, Microsoft MVPs, and UtterAccess VIPs. I specifically notified Access and Excel MVPs as well as the VIP group at UtterAccess.
While there weren’t quite as many opinions as their were people completing the survey, there certainly is a broad range of opinions.
Dennis, an UtterAccess member who was unable to complete the survey because he was away while it was open for response posted a forum message that pretty well sums up my own position on the question. He said in part,
“Commenting code was described by one of my college instructors as one of the most important, but least prioritized steps of the programming process. And I believe he was (and is) 100% correct.
One should never assume that the purpose of a block of code is self-evident. Even if you've used the same module over and over, that module should be documented so that someone (even you) in the future will quickly be able to see HOW and WHY a block of code is doing what it does.
Commenting costs nothing to compiled code, and is worth it's weight in gold to people charged with improving and re-using code. After all, the cliché says "time is money" and the amount of time saved with a few lines of text within a block of code can be enormous.
There, that's about it, in a nutshell.”
I should mention that I did not submit a response to the survey myself; I wanted to leave the answers to others and let the results fall where they may. The results were not particularly startling. They do reflect a broad range of opinion among the respondents. More than half of the 57 people answering the survey rated commenting as being either very important or absolutely essential.
The numerical results, however, only tell part of the story. The survey included two open-ended questions, ‘Briefly describe how you use commenting in your own work and the depth of detail you include in your comments.’ and ‘What would you describe as the single most important reason for including comments in programming code?’
A common theme for the first set of open-ended responses was, “to help me remember what I did and why.” Some of these comments expanded the theme to include “others who might have to follow-up on my work.”
In response to the second open-ended question, one person put it this way, “1stly To remind me of what I wrote and how the code works...I sometimes don't view project for long periods of time. 2ndly so that if or when I expire someone else can take up where I left off.”
There were a few problems with the survey, some caused by my oversight when I designed it and some caused by the the survey software itself. Two people reported either being unable to submit their responses on the the survey site or being unable to edit/include comments that were greater than 255 character. I won’t complain too loudly about the survey site, however, since I used the free survey tool that is available if you register on the site.
As to survey design issues, I neglected to include a ‘none’ category in the question about programming languages other than VBA. That cause the ‘other’ response to be somewhat ambiguous.
All in all, however, I’d have to say that devising and implementing the survey and analyzing the results has been an interesting exercise. I have a few other ideas that I may try in the future. The full survey report is available in pdf format here.
I would like to publicly thank the UtterAccess VIPs and my fellow MVPs who took the time to respond to the survey.
Don’t be fooled!!
I was quite surprised yesterday to see reference to an article I wrote several years ago, Data Modeling for the Access Newcomer is an internet newsletter. I am not going to name the newsletter here because I don’t want to give it any free publicity. You won’t find it by links that I provide.
The particular newsletter follows the questionable practice of posting teasers about articles with links that lead to a sign-up page for their paid service. Once you have signed up, chances are all you will find is yet another link, this time to another site where the piece was available to you free of charge all the time. So you have just paid for, or at least signed up for a trial of, a service that frequently simply provides you links to pages and sites that a freely available without ever going near their service. If it was a free trial, you can bet they will then be soliciting you for a paid subscription. Definitely don’t buy the subscription unless you feel you are getting real value for your money.
In the case of my article, the full text of the article is freely available in Garry Robinson’s excellent VB123 blog. Garry recently purchased rights to the best years of Smart Access magazine (the years when Peter Vogel was the editor.) You can purchase electronic versions of sets of the magazine from Garry’s vb123 site if you are interested in a set of excellent articles that spanned the years from October 1996 to April 2006. That is almost 10 years of monthly issues with articles by hundreds of Access experts.
If you are just interested in my article, this link Data Modeling for the Access Newcomer, will take you to the full text of the article. Garry is very generously publishing the full text of individual Smart Access articles in his blog. He has a convenient index to the Smart Access articles.
There is an old expression that says, “Why buy the cow, when you can get the milk free?” While the expression can have a somewhat off-colour meaning, depending on its context, I think it deserves a paraphrase here, “Why pay for a link when you can get to the real article free?” If someone is trying to sell you links, use your favourite search engine to find your own links. It won’t cost you a cent.
Creating Tables
In the last installment we explored the many to many relationships that exist between our various table. At that point we had not yet created the tables. This article will deal with the nuts and bolts of actually creating a table.
A word about names
The names you use when you create your database objects are important and should follow certain guidelines. Access reserves certain words for its own use. Logically these words are known as reserved words. Unfortunately some of these words are the first that comes to mind when you are trying to name fields for example. In this article I discussed at a conceptual lever, the tables we need in the Ice Cream Parlour database. If you look back to that article you will see names like ‘Name”, “Description”, and “Type”. These words all have special meaning within Access and should not be used to name Access objects.
So you will notice that the field names in the relationship diagrams in my last article are different from those I used in the conceptual diagrams. So, for example I have a field ‘strSundaeName’ rather than simply ‘Name’. What about the ‘str.’ That part of the name comes from a convention I follow to add a prefix to the name that indicates the datatype of the field. Many Access developers do not use prefixes for field names. So SundaeName would be perfectly acceptable and, in fact, preferred by many developers.
On the other hand, many developers do follow a naming convention that prefixes the names of Access objects like tables, queries, forms and reports, with three characters to signify the type of object to which the name pertains. So, for example, the Sundaes table is actually called ‘tblSundaes’.
Notice also that tables are usually plural. That is because the table contains records where each record is one example (or instance) of the subject of the table. So, tblSundaes has fields with names like strSundaeName (or SundaeName, if you prefer.)
Creating a table
There are several ways to create a table in Access. Although I don’t recommend it, you can design a table by entering data into a datasheet. Access will determine the data type for each field based on the data you enter. And unless you are careful to name each field, Access will assign such helpful field names as Field1, Field2, etc.
In Access versions prior to 2007 there are table creation wizards and in 2007 there are table templates to help you out. Unfortunately, tables created by wizards or from Access 2007 templates have field names that do not follow accepted naming standards. They include spaces in the field names. Now, while this may seem perfectly natural to you if you are an Access beginner, those spaces will come back to haunt you when you decide to enhance your work using advanced features like Visual Basic for Applications (VBA).
I prefer to create all tables using the Table Design View. Before we go there, however, we should map out the fields we will need and determine what their respective data types should be. For the sake of illustration I am going to deal with creating one of the tables we have decided we need. If you are following along and creating your own ice cream parlour database, the best way for you to learn will be for you to create the other tables on your own. I will be providing a link to my version of the database with all tables created.
Before we look at the table designer, let’s summarize the information we will need for each table. I am indicating two possible names for each field. The first name follows the naming convention I prefer to use. The second is a valid name in a format that omits the data type prefix. Whichever style you choose, it is important to be consistent throughout the database.
Sundaes - tblSundaes
attribute | field name | alternate name | data type | data size | notes |
Primary Key | idsSundae | SundaeID | Autonumber | long integer | |
Name | strSundaeName | SundaeName | Text | 25 |
Dishes - tblDishes
attribute | field name | alternate name | data type | data size | notes |
Primary Key | idsDish | DishID | Autonumber | long integer | |
Name | strDishName | DishName | Text | 25 | |
Type | lngDishType | DishType | Number | long integer | foreign key – used to find the dish type description in the types lookup table |
Sizes - tblSizes
attribute | field name | alternate name | data type | data size | notes |
Primary Key | idsSize | SizeID | Autonumber | long integer | |
Name | strSizeName | SizeName | Text | 25 | |
Type | lngSizeType | SizeType | Number | long integer | foreign key – used to find the dish type description in the types lookup table |
Flavors - tblFlavors
attribute | field name | alternate name | data type | data size | notes |
Primary Key | idsFlavor | FlavorID | Autonumber | long integer | |
Name | strFlavorName | FlavorName | Text | 25 |
Ingredients - tblIngredients
attribute | field name | alternate name | data type | data size | notes |
Primary Key | idsIngredient | IngredientID | Autonumber | long integer | |
Name | strIngredientName | IngredientName | Text | 25 | |
Type | lngIngredientType | IngredientType | Number | long integer | foreign key – used to find the dish type description in the types lookup table |
Those are the basic definitions of our five central table. As already noted, we will need additional tables in the database to allow us to connect these central tables together so that the database reflects the one to many relationships between them. We will also need a lookup table for types the type descriptions used by tblDishes, tblSizes, and tblIngredients.
Coming next: Using the table designer.
Access 2010 Preview
While an actual release date is still to be announced, the next version of Office and Access are looking pretty exciting. For an overview of what’s coming in Access, have a look a the Access team blog.
Connecting the dots – well the main tables, anyway
Thanks to grovelli who prodded my about the next installment in the Ice Cream Parlour tutorial, here it is.
When we last looked at the ice cream parlour database, we had identified the main tables of the database:
- sundaes
- dishes
- sizes
- flavors
- ingredients
For now, let’s focus on how to connect these tables together rather than on the contents of each field. You may recall that we identified the relationships between most of the pairs of tables turned out to be many to many. That is, for example, one sundae may use many ingredients and each ingredient can be used in more than one sundae.
To keep it simple I am going to focus on just this one pair of tables, sundaes and ingredients. Let’s say, for the sake of argument, that we have come up with a recipe for what we are going to call Chocoholic’s Mega Gooey Sundae Delight. Because we have chosen to use autonumber primary keys when we enter this recipe title in the Sundaes table access assigns 621 as the primary key. Now, if we need to refer to our Mega Gooey Sundae Delight outside of the table all we (or Access) need to know is that this particular Sunday is number 621 in our table.
Actually the end user does not need to know the value of the primary key at all. There are ways of getting the value and causing it to be entered in other tables without actually having to actually know the number.
So far, so good. Now the Mega Gooey Sundae Delight recipe calls for these ingredients
- Chocolate Ice Cream (832)
- Chocolate Sauce (365)
- Chocolate Sprinkles (798)
- Marshmallow Sauce (922)
- Toasted Almond Slivers (305)
After each ingredient name, I have shown for the sake of this illustration, the primary key that Access assigned to each of these ingredients when they were added to the ingredients table. The actual number doesn’t matter. What is important is that no two ingredients share the same number. To put it in Access’s terms, the values are unique. That means that we can be confident that whenever we refer it item 922 in the ingredients table, we are talking about Marshmallow Sauce.
Here is the relationship diagram for these two tables:
The junction table I have been describing is tblSundaeIngredients. The infinity symbol indicates that that side of the relationship is ‘many’, meaning that each sundae in the tblSundaes can have many corresponding records in the junction table. Similarly, each ingredient can have many corresponding records in the junction table as well.
I will go through the process of actually creating the tables and relationships in later installments of this series of articles. For now, I just want to focus on what things look like when we bring together a sundae with its ingredients using a junction table.
To keep things simple, I have included in the diagram only the fields and records necessary to illustrate the point. Notice how the junction table includes only numbers and those numbers are the same as the primary keys of each of the ingredients in tblIngredients. This is typical of tables that are related. The fields lngIngredient and lngSundae are known as foreign keys. In other words the values in those fields tell us what values we are talking about in the other (or primary) table.
Next time, we will take a look at actually creating these Access tables. Following that, we will look at the process for creating relationships.
Great News - I have been recognized as an MVP for another year
Yesterday, July 1, I received the notification that I have been recognized as a Microsoft Most Valuable Professional for the third year in a row. This is indeed a great honour, considering that there are fewer than 5,000 MVPs world-wide. One of the benefits of being an MVP is that we have a designated person (our MVP lead) at Microsoft) with whom we can correspond on a personal basis. You can read more about the MVP program on the MVP website.
Tables for the Ice Cream Parlor
Just as a real ice cream parlor needs tables where our patrons can sit and enjoy out products, our database model of ice cream sundaes will need tables in which to store information about our products.
In the previous installment of this series, we fleshed out the list of tables database will need. These are our main tables:
- ingredients
- dishes (containers)
- sizes
- sundaes
- flavors
Because we will be combining ingredients in various ways with various container sizes and ingredients actually come in several flavors, we will need some additional tables to help us model the combinations. These tables will include:
- sundae ingredients
- ingredient flavors
- sundae sizes
- container sizes
- sundae containers
Now it is time to determine what fields to include in each table. You may be starting to find this list just a little overwhelming. Try not to panic. It is really not all that bad as long as you tackle things a little bit at a time. So we will move ahead, slowly but confidently, one table at a time. For now, let's focus on the five central tables mentioned above.
Table definition refers to identifying the fields that are needed to describe the subject (or domain) of each table. So when I think about a table, I start to think about the kinds of information I need to describe the subject of the table.
We will keep these basic guidelines in mind:
- each table describes only a single subject (entity)
- the fields included in each table should describe the subject of the table (attributes).
- data will be subdivided across multiple tables in order to
- avoid duplication of data, and
- avoid repeating groups of columns
I find that, in a database as focused on a single business solution as the ice cream sundae database is, a single table emerges as the central table at the heart of the application. Other tables in the database are needed only because they will have information that pertains to the central table.
So, for us, the central table appears to be the sundaes table. Let's start there. What information do I need to store to describe each sundae? Obviously each sundae needs a name. It will also need ingredients and, since I plan to offer each sundae type in a variety of sizes, it will need size information.
However, storing size and ingredient data in the main sundaes table will lead to immediate design problems. While I might be certain ahead of time exactly how many sizes I will be offering and the maximum number of flavors might be used in a sundae, including that information directly in the sundaes table will break one of our basic guidelines. I would have to have fields like flavor1, flavor2, flavor3, ingredient1, ingredient2, ingredient3. In database terms these would be examples of repeating columns.
So, what's the problem? Although not apparent at the outset of planning, repeating columns make retrieving useful information from stored data, unnecessarily complex. Even more important, repeating columns put serious limits on the future use of the database. No matter how certain you are ahead of time that you are describing how something is now and will ever remain the same, it is just not that easy to predict the future. If I "know" that I will only ever offer three sizes of sundae, small, medium, and large, the database (if I have included three size fields in the sundaes table) would not be able to handle changes I might have to make in order to remain competitive. Say, for example, that upstart competitor down the street starts stealing my customers because she has added a fourth or fifth size.
I have tried to describe the process by which I have determined what fields belong in the sundaes table. The process for deciding what fields to include each of the other main tables is the same. The following table shows the results of this analysis:
sundaes | dishes | sizes | flavors | ingredients |
Name | Name | Name | Name | Name |
Type | Type | Type | ||
Description | Description |
You may find that the list of fields in each table is somewhat short. Each table includes a name field. The sundaes and flavors tables don't have any other fields. That's because most of how we describe sundaes, for example, is stored in other tables. Flavor names, on the other hand are pretty much self-descriptive.
The dishes, sizes and ingredients tables have type fields. We will use these fields to categorize dishes, sizes and ingredients, respectively. Dishes may be either edible, disposable (plastic for takeout) or reusable (glass or metal for eat-in.) Sizes may refer, for example to quantity when referring to ingredients, to capacity when referring to dishes, or to the end-product size description (small, medium, large, for example) when referring to sundaes. Ingredients may be principal ingredients, toppings, or garnishes, for example.
Now we have a working definition of our main tables. In the next article we will define the additional tables we will need to flesh out the connections needed between the main tables.
Let's Build Some Tables
In the last article we looked at the relationships that exist between the various products we will be using to create ice cream sundaes. These 'real world' relationships dictate the relationships we will need to establish between the tables of the database.
In this article we are going to look at what information we should be including in each table. Before doing that however, there is at least one more table that we should include in the database, flavors. Since each flavor can apply to many ice creams and some ice creams have multiple flavors, the relationship between ingredients and flavors is many to many. It is possible that some other ingredients may be multi-flavored as well but one multi-flavored ingredient is enough to make the relationship many to many.
It's important to define the relationships before finalizing table design because one to many and many to many relationships require different table structures. For a one to many relationship, you include one field in the 'many' table to identify the 'one' table record to which each 'many' record belongs. Many to many relationship require this information to be stored in an separate table with one field for each of the partner tables.
Guess what!! We have just have just identified the need for several additional tables in our 'simple' ice cream sundae database. We will need one table for each of the many to many relationships. One reason for doing detailed planning and design before actually beginning to build the actual database is to try to uncover and resolve any possible data management problems and to ensure that all the database will include all information necessary to fulfill the database's stated purpose.
In Know Your Data (Part 3) we defined the purpose of our ice cream sundae database:
This database stores information about the quantity of contents used to make ice cream sundaes. It assists with the design of new sundaes and provides reports of the ingredients required to make each type of sundae.
We have also defined a list of tables that we will need to manage the data:
- ingredients
- dishes (containers)
- sizes
- sundaes
- flavors
Now it is time to decide what data needs to be included in each table. Before we do that we should review some terms and principles required for good relational table design.
- Each table should contain information about only one topic or subject (formally known as an entity.
- All examples of a topic should be included in one table (if you have are dealing with people and occupations, you would have one people table, not separate tables for each occupational group, for example.)
- Each table has one or more fields that describe the subjects or topics stored in the table.
- Each table should have a primary key that uniquely identifies each record in the table. (I am going to leave for another time the discussion of the alternative types of primary keys.)
- A record is the collection of fields that describe one of the topics of the table.
- Data should be stored only once.
There is a set of rules known as the forms of normalization that are the guiding principles for relational database design. If you a new to database design, your initial efforts will most likely run afoul of normalization so don't be surprised when the response to questions you may ask an experienced developer about designing forms or reports refers you back to normalization issues in your basic database design.
In case you haven't noticed, we have yet to do anything with Access itself. That is because knowing how to use Access is only part of the story in building a successful database for personal or small enterprise use. We will be using Access to build and run the database but we can't build it until we have a solid design.
In the next article we will (finally) design our the tables that we will have Access manage for us.
Dr. Phil Time - Relationships
In this simple example, we have been developing a database to assist with the design of ice cream sundaes.
In the last article in this series, we developed the statement of purpose for the database:
This database stores information about the quantity of contents used to make ice cream sundaes. It assists with the design of new sundaes and provides reports of the ingredients required to make each type of sundae.
We also determined that we will need at least four tables if the database is to be properly structured:
- ingredients
- dishes (containers)
- sizes
- sundaes
I am going to save deciding the contents of each of these tables for the next article and focus now on how the tables relate to each other. (After all, we want this to be a relational database.)
The process to determine the type of relationship that exists between any two tables is quite straight-forward and perhaps a bit tedious. Try not to let the tediousness of the task of getting in the way of doing it. Correctly defining the database's relationships is absolutely essential!!
Unlike real-world relationships, in Access there are always exactly two partners in any relationship. You define each relationship by considering one pair of tables. By filling in the blanks in two simple statements, you can make a simple conclusion about the type of the relationship.
So we are going to look at pairs of tables until we have determined what the relationship is between each possible pair of tables using these three statements.
- Each record in table A can have (zero/one/many) records in table B
- Each record in table B can have (zero/one/many) records in table A
- Therefore this is a (one to many/one to one/many to many) relationship.
So here are the pairs of tables and their relationships.
With four tables there are six possible relationships but not all tables will share a relationship.
sundaes <---> dishes
(Just to be clear, the dishes table stores information about types of dishes so the relationship definition deals with how each sundae will relate to dish types.)
- Each sundae can have one dish
- Each dish can have many sundaes
- Therefore this is a one to many relationship
sundaes <---> sizes
- Each sundae can have many sizes
- Each size can have many sundaes
- Therefore this is a many to many relationship
sundaes <---> ingredients
- Each sundae can have many ingredients
- Each ingredient can be used in many sundaes
- Therefore this is a many to many relationship
ingredients <---> dishes
- Each ingredient can have no dishes
- Each dish can have no ingredients
- Therefore there is no relationship between ingredients and dishes
ingredients <---> sizes
- Each ingredient has no records in the sizes table
- Each size has no records in the ingredients table
- Therefore there is no relationship between ingredients and sizes
dishes <---> sizes
- Each dish has one size
- Each size could be applied to many dishes
- Therefore there is a one to many between sizes and dishes.
Remember that when you are describing relationships, you are not defining the relationship. A relationship is what it is; calling it by another name will not change its essential nature. Your job is to identify accurately the essential nature of each relationship in the database.
A couple of things have come to light in this relationship analysis. First, sizes are used in two somewhat different contexts. Sundae sizes refer to the size (small, medium, large) in which the sundae will be marketed. Dish sizes on the other hand refer to the capacity of the dish, how large a sundae it can comfortably contain. The two uses may or may not similar descriptions. A sundae might be described as small medium or large. So might a dish but dishes could alternatively be described in terms of units of measure (grams, ounces, etc.)
So it might be worthwhile thinking about an additional table to store the possible units of measure (metrics.) Whether this would be necessary or merely a possibly good idea would depend in part on how many possible units of measures apply.
Including a metrics table requires further relationship analysis. Before we can describe the relationship between sundaes and metrics in particular, it is important to be clear what constitutes a sundae. So far it looks as if we have defined a sundae as the combination of ingredients and a particular container. But there is one more factor that distinguishes one sundae from another: size.
So a banana split consists of vanilla, chocolate, and strawberry ice cream, banana, chocolate syrup, crushed pineapple, walnuts, whipped cream, and cherries, regardless of whether the sundae is small medium or large. For data management purposes, a small banana split is different from a medium or large banana split and it is the size that distinguishes them from each other.
metrics <---> sundaes
- Each metric applies to many sundaes
- Each sundae has one metric
- Therefore this is a one to many relationship
metrics <---> ingredients
- Each ingredient has many metrics
- Each metric apples to many ingredients
- Therefore this is a many to many relationship
metrics <---> dishes
- Each metric applies to many dishes
- Each dish has one metric
- Therefore this is a one to many relationship
metrics <---> sizes
- Each metric applies to many sizes
- Each size has one metric
- Therefore this is a one to many relationship
Now, you might be asking how can a metric apply to many dishes. That is a perfectly legitimate question simply because I haven't fully defined what I mean by a dish.
For this definition, let's look to the real world as it applies to ice cream shop. We have already seen that dishes come in several sizes. In my shop, I intend to have both edible and inedible dishes for each of the sizes. Perhaps, in the future, I might have several types of edible dishes (waffle or chocolate, for example.) It is the combination of size and dish type that distinguishes one small dish from another.
Raising that point means that we must think about yet another set of relationships. I'm going to leave that decision aside for the moment.
Next time we will take a look at table definitions, what fields each of our tables need.
Know Your Data (part 3)
After an unintentional hiatus, I'm back with part three of this discussion of Access database design considerations.
The first two articles (Know Your Data!) discussed planning for the data you need your database to manage. The third essential component in knowing your data, is understanding how data in the various tables of the database relate to data in other tables (that's why we call it a relational database.)
However, it's a bit premature to talk about relationships. First we need to have a simple database example and an understanding of the tables it requires. Once we have an understanding of the tables, we can then look at their relationships.
I'm going to build this example around a simple single purpose database but, regardless of the size and complexity of the database the same basic design principles apply .
Let's say, for the sake of discussion that I own an ice cream shop.I have decided that I want to use a database to help me design ice cream sundaes that will show me the kinds and quantities of ice cream and other ingredients each particular sundae type requires. This information will help me determine how much of each to stock when I start to sell each sundae.
The first step in designing any database is to devise a simple yet clear 'statement of purpose' for it. As you build the database keeping the statement of purpose in mind will keep you on track so that the end product will do everything it was supposed to do while, at the same time, does not just grow beyond recognition to do things you did not originally intend. In other words, the statement of purpose helps you focus your work and keep it 'in scope.'
I like to play a little trick with language when I write a statement of purpose by stating it as if the database already exists. So the statement of purpose for my ice cream sundae database might go something like this: This database stores information about the quantity of contents used to make ice cream sundaes. It assists with the design of new sundaes and provides reports of the ingredients required to make each type of sundae.
Now I can use that simple statement of purpose to begin to decide exactly what kind of data I will need to include in the database. Here's a simple 'brain dump' of what goes to make up an ice cream sundae:
|
|
|
While thinking about this list, I realize that I need to include the possibility of having various sizes of sundaes. Since a database is really just a model of the real world, I will need to include sizes in the basic information about each sundae I design. Even though I intend to have a number of sizes, I realize that to keep sundae management simple, I should limit the number of sizes available to three or four.
I'm now at the third stage of my design where I need to decide on what tables I need. Since I want to restrict the variety of sizes I sell, a table that describes each size might be useful. A table of dishes or containers might also be useful. And what about a table for ice creams and one for toppings.
Now that just might be one table too many. Aren't ice creams and topping just different ingredients? So let's just have a single table for ingredients. Here is my initial table list:
- ingredients
- dishes
- sizes
One important table is missing however. That is the sundaes table that brings together all of the information that describes an ice cream sundae, our final product. So we will add one more table:
- sundaes
In the next article, we refine the database design by determining the relationships between the tables.