Electric Type

Multimedia

About Us

News

Help

Your First Database
Lesson 2

by Jay Greenspan

Page 5 — Working with Access

When you open Access (or whatever database you're using), you'll be asked what kind of database you want to start with. Select Blank Database. Then, when it asks you where you want to save your database, choose a folder that has no read/write restrictions. If you're using Windows NT, folders within the C:\winnt\profiles directory may have restrictions you're not aware of. I suggest creating your database in the folder that serves out your Web pages.

Next, go over to the Table tab and click New. We'll use the Design mode to transfer the information from our chart on the previous page (along with a bit more detail) into this area. I have no intention of holding your hand through this process. You're big boys and girls, and you can play with the icons and drop-down menus to figure out what's going on.

I will, however, give you the following advice. First, make sure you have your Primary Key defined. Next, be as restrictive as you can. For instance, the Size property of the email field defaults to 50. Since few email addresses will be that long, and leaving it at that length would take up more disk space than necessary, you might want to reduce the maximum length. Also, don't use spaces in your field names - it'll be a big bother down the line.

Now that we've created our tables, we're going to establish the relationships between the tables. But first, I have another definition for you. You remember the Cars and the Clients tables, right? Let's say the Clients table contains the following information.

Take a gander at the carID field. Notice the value in both records is 2. By looking at the Cars table below, we can see that both Jay Greenspan and A. Monkey drive Jaguars.

This bit of info tells us there is a specific type of relationship between carID in the two tables. Since one carID from the Cars table can exist in many records in the Clients table, this is called a one-to-many relationship.

The one-to-many is the most common type of relationship in relational databases, and it is the only type we'll use in this database. There are a couple other types you should be aware of: one-to-one and many-to-many. Read up on them when you can.

We know we have a number of One-to-Many relationships, and we should let Access know about them. Choose Relationships from the Tools menus. Then insert all the tables onto the screen. You should see little boxes that represent the tables in your database. Create the relationship by clicking on the field on the One side of the relationship and drag it to the corresponding field on the Many side. In the screen that appears, click on the Create button, and you're set. When you're done, there should be a line connecting these fields, like so:

By the time we're done drawing all these relationships, you'll see that every table is connected to something, and that looks pretty cool.

If you don't believe me, download the database and take a look for yourself. This would be a great opportunity to peruse the tables and see how the data is defined and, more importantly, how the tables work together.

Now that we have a database, we need to make it accessible to our Web server. Let's do that, shall we?

next page»


Lesson 1  

Lesson 2  

Lesson 3  

Lesson 4  

Authoring Home  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.