Determining What Tables You'll Need

How many tables will you need? Technically, you will only need one. That's the minimum a database can function with. However, the biggest mistake most people make with Access is to put too much information in one table. Access is a relational database program; unlike more simple database programs, it's meant to handle lots of tables and create relationships among them. Figure 2.1 shows a list of tables in a database that keeps track of the employee hours spent on various projects.

Figure 2.1. Access really shines when you take advantage of its capability to store many tables.


Plan Tables Now!

You should plan your tables before you create your database because changing a table's structure once it's been filled with data is difficult.


Another big mistake people make is to try to make each table look like a stand-alone report. For instance, they might repeat a customer's name and address in all eight tables because they want that information readily available when it's required. This is a waste! You can easily create a report or form that includes this information whenever you need it; it needs to appear in only one table.

Normalizing Your Database

When a database suffers from poor table organization, experts say it's not normalized. There are rules that govern how a relational database should store its tables; these are the rules of Data Normalization.

Data Normalization

Make the tables as efficient and compact as possible to eliminate the possibility for confusion and error.


There are five normalization rules, but the latter ones are fairly complicated and used mostly by database professionals. In this lesson, I'll explain the first two normalization rules, which are all a beginner really needs to understand in order to avoid major mistakes.

Normalized Wizards

Luckily, database professionals had a hand in creating Access's Database Wizard, so any tables you create using this feature (see Lesson 5) will be normalized.


1. Avoid Repeated Information

Let's say that you want to keep contact information on your customers along with a record of each transaction they make. If you kept it all in one table, you would have to repeat the customer's full name, address, and phone number each time you entered a new transaction! It would also be a nightmare if the customer's address changed; you would have to record change every transaction.

Customer Name Customer Address Customer Phone Order Date Order Total
ABC Plumbing201 W. 44th St.(317) 555-23942/5/96$155.90
ABC Plumbing201 W. 44th St.(317) 555-23945/14/96$90.24
ABC Plumbing201 W. 44th St.(317) 555-23947/9/96$224.50
Jack's Emporium1155 Conner Ave.(317) 555-45016/6/95$1,592.99
Jack's Emporium1155 Conner Ave.(317) 555-45017/26/96$990.41
Millie's Pizza108 Ponting St.(317) 554-23498/29/96$39.95

A better way is to assign each customer an ID number. Include that ID number in a table that contains names and addresses; then include the same ID number as a link in a separate table that contains transactions.

Table . Customers Table
Customer ID Customer Name Customer Address Customer Phone
1ABC Plumbing201 W. 44th St.(317) 555-2394
2Jack's Emporium1155 Conner Ave.(317) 555-4501
3Millie's Pizza108 Ponting St.(317) 554-2349

Table . Orders Table
Customer ID Order Date Order Total
12/5/96$155.90
15/14/96$90.24
17/9/96$224.50
26/6/95$1,592.99
27/26/96$990.41
38/29/96$39.95

2. Avoid Redundant Data

Let's say you want to keep track of which employees have attended certain training classes. There are lots of employees and lots of classes. One way would be to keep it all in a single Personnel table, like this:

Employee Name Employee Address Employee Phone Training Date Class Taken Credit Hours Passed?
Phil Sharp211 W. 16th St.(317) 555-43215/5/96Leadership Skills3Yes
Becky Rowan40 Westfuekd Ct.(317) 555-39055/5/96Customer Service2Yes
Nick Gianti559 Ponting St.(317) 555-76836/15/96Public Speaking9Yes
Martha Donato720 E. Warren(317) 555-29305/5/96Public Speaking9No
Cynthia Hedges108 Carroll St.(317) 555-59906/15/96Customer Service2Yes
Andrea Mayfair3904 110th St.(317) 555-02936/15/96Leadership Skills3Yes

But what if an employee takes more than one class? You'd have to add a duplicate line in the table to list it, and then you have the problem described in the previous section—multiple records with virtually identical field entries. What if the only employee who has taken a certain class leaves the company? When you delete that employee's record, you delete the information about the class's credit hours, too.

A better way would be to create separate tables for Employees, Classes, and Training Done, like so:

Table . Employee Table
Employee ID Employee Name Employee Address Employee Phone
1Phil Sharp211 W. 16th St.(317) 555-4321
2Becky Rowan40 Westfield Ct.(317) 555-3905
3Nick Gianti559 Ponting St.(317) 555-7683
4Martha Donato720 E. Warren(317) 555-2930
5Cynthia Hedges108 Carroll St.(317) 555-5990
6Andrea Mayfair3904 110th St.(317) 555-0293

Table . Class Table
Class ID Class Credits
C1Leadership Skills3
C2Customer Service2
C3Public Speaking9

Table . Training Table
Employee ID Date Class Passed?
15/5/96C1Yes
25/5/96C2Yes
36/16/96C3Yes
45/5/96C3No
56/15/96C2Yes
66/15/96C1Yes

Summary: Designing Your Tables

Don't be overwhelmed by all this information about database normalization; good table organization boils down to a few simple principles:

  • Each table should have a theme; for instance, Employee Contact Information or Customer Transactions. Don't try to have more than one theme per table.

  • If you see that you might end up repeating data in a table in the future, plan now to split the information that will be repeated into its own table.

  • If there is a list of reference information you want to preserve (such as the names and credit hours for classes), put it in its own table.

  • Wherever possible, use ID numbers, as they'll help you link tables together later and help you avoid typing errors that come from entering long text strings (such as names) over and over.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.229.113