Skip to main content

Creating databases with multiple tables

Creating databases with multiple tables
Whether your database holds 100 records or 100,000 records (or more), if you need to keep separate tables and relate them for maximum use of the information, you need a relational database — and that’s Access. How do you know whether your data needs to be in separate tables? Think about your data — is it very compartmentalized? Does it go off on tangents? Consider the following example and apply the concepts to your data and see if you need multiple tables for your database.

The Big Organization database

A large company has data on their customers and their orders, the products the company sells, its suppliers, and its employees. For a complex database like this one, you need multiple tables, as follows:

  • One table houses the customer data — names, addresses, phone numbers, and e-mail addresses.
  • A second table contains the customers’ orders, including the name of the customer who placed the order, the salesperson who handled the sale, shipping information, and the date of the order.
  • A third table contains information on the products the company sells, including product numbers, supplier names, prices, and the number of items in stock.
  • A fourth table contains supplier data — about the companies from which the main organization obtains its inventory of products to resell to customers. The table contains the company names, their contact person, and the address, e-mail, and phone number information to reach them.
  • A fifth table contains employee data — from the date they were hired to their contact information to their job title — and also contains notes about them, sort of a summary of their resumes for reference.

Other tables exist, too — to keep a list of shipping companies and their contact information (for shipping customer orders), an expense table (for the expenses incurred in running the business), and other tables that are used with the main four tables. The need for and ways to use the main tables and these additional tables are covered later in this book, as you find out how to set up tools for data entry, look up records, and create reports that provide varying levels of detail on all the data you’ve stored.

Tip:

Because you don’t have to fill in every field for each record — in any table in the database — if you don’t have a phone number or don’t know an e-mail address, for example, it’s okay to leave those fields blank until you’ve obtained that information.

Fail to plan? Plan to fail

If you think carefully about your database, how you use your data, and what you need to know about your employees, customers, volunteers, donors, products, or projects — whatever you’re storing information about — you can plan

  • How many tables you’ll need
  • Which data will go into which table
  • How you’ll use the tables together to get the reports you need

Of course, everyone forgets something, and plans change after a system has already been implemented. But don’t worry — Access isn’t so rigid that chaos will ensue if you begin building your tables and forget something (a field or two, an entire table). You can always add a field that you forgot (or that some bright spark just told you is needed) or add a new table after the fact. But planning ahead as thoroughly as possible is still essential.

Tip:

As part of thorough planning, sketch your planned database on paper, drawing a kind of flow chart with boxes for each table and lists of fields that you’ll have in each one. Draw arrows to show how they might be related — it’s sort of like drawing a simple family tree — and you’re well on your way to a well-planned, useful database.

Here’s a handy procedure to follow if you’re new to the process of planning a database:

1. On paper or in a word-processing document, whichever is more comfortable, type the following:

  • A tentative name for your database
  • A list of the pieces of information you plan on getting from that database on a daily or regular basis

2. Now, based on that information, create a new list of the actual details you could store:

List every piece of information you can possibly think of about your customers, products, ideas, cases, books, works of art, students — whatever your database pertains to. Don’t be afraid to go overboard — you can always skip some of the items in the list if they don’t turn out to be things you really need to know (or can possibly find out) about each item in your database.

3. Take the list of fields — that’s what all those pieces of information are — and start breaking them up into logical groups.

How? Think about the fields and how they work together:

  • For example, if the database keeps track of a library of books, perhaps the title, publication date, publisher, ISBN (International Standard Book Number, which is unique for each book), price, and page count can be stored in one group, whereas author information, reviews, and lists of other titles by the same author or books on the same topic can be stored in another group. These groups become individual tables, creating your relational database of books.
  • Figure out what’s unique about each record. As stated in the previous point, you need a field that’s unique for each record. Although Access can create a unique value for you if no unique data exists for each record in your database, it’s often best to have such a field already in place, or to create such a field yourself. Customer numbers, student numbers, Social Security numbers, book ISBNs, catalog numbers, serial numbers — anything that isn’t the same for any two records will do.

With a big list of fields and some tentative groupings of those fields at the ready, and with an idea of which field is unique for each record, you can begin figuring out how to use the data.

4. Make a list of ways you might use the data, including

  • Reports you’d like to create, including a list of which fields should be included for each report
  • Other ways you can use the data — labels for mailings, product labels, catalogue data, price lists, contact lists, and so on

5. List all the places your data currently resides — on slips of paper in your pocket, on cards in a box, in another program (such as Excel), or maybe through a company that sells data for marketing purposes.

With this planning done, you’re ready to start building your database. The particulars of that process come later in this chapter and in subsequent chapters, so don’t jump in yet. Do pat yourself on the back, though, because if you’ve read this procedure and applied even some of it to your potential database, you’re way ahead of the game, and we’re confident you’ll make good use of all that Access has to offer.

Comments

Popular posts from this blog

Databases with user forms

When you’re planning your database, consider how the data will be entered: If you’ll be doing the data entry yourself, perhaps you’re comfortable working in a spreadsheet-like environment (known in Access as Datasheet view), where the table is a big grid. You fill it in row by row, and each row is a record. Figure 1-1 shows a table of customers in progress in Datasheet view. You decide: Is it easy to use, or can you picture yourself forgetting to move down a row and entering the wrong stuff in the wrong columns as you enter each record? As you can see, there are more fields than show in the window, so you’d be doing a lot of scrolling to the left and right to use this view. You may want to use a form (shown in Figure 1-2) instead. A form is a specialized interface for data entry, editing, and for viewing your database one record at a time, if Someone else will be handling data entry Typing row after row of data into a big grid seems mind-numbing Figure 1-1: Datasheet view ...

Adding buttons to the Quick Access toolbar

Speaking of the Quick Access toolbar and all the ways you can access commands for customizing it, try this to add commands: 1. With any database open (so that the Ribbon tabs are displayed), rightclick any of the buttons on any of the tabs. You can also right-click the Quick Access toolbar or any Ribbon tab. 2. Choose Customize Quick Access Toolbar. The Access Options dialog box opens (shown in Figure 2-13), with its Customization options displayed. Figure 2-13: Pick a command category and a command to add to the Quick Access toolbar. 3. Click the Choose Commands From drop-down list and choose a command category. A list of Popular Commands appears by default. 4. From any (or each) category, choose the commands you want to see at all times in the Quick Access toolbar by clicking them one at a time and then clicking the Add button. As you click the Add button, the command you chose is added to the list on the right. Note that you have up- and down-pointing triangles o...

Access Field Types and Uses

A field, you remember, is where your data lives. Each field holds one piece of data, such as Last Name or Batting Average. Because there are so many different kinds of information in the world, Access offers a variety of field types for storing it. In fact, Access puts the following field types at your disposal: Short Text Long Text Number Currency Date & Time Yes/No Lookup & Relationship Rich Text Attachment Hyperlink OLE Object Calculated There’s also an Autonumber field type, which is applied automatically to the first field in a new, blank database. The types just listed are those available for fields you create in addition to that first field — the ones that will contain your data. For now, suffice it to say that the Autonumber field is a field that contains an automatically-generated number so that each record is unique in that it has a unique autonumber, or ID. You get the word about the need for (and ways to create) unique fields later on, in Chapter ...