Understanding the Database Structure


The database that has been built for Retro's Cycles is a very simple one. If you have Microsoft Access installed on your workstation, download the retros_cycles_99300d2.mdb database from the ColdFusion section of the companion website and familiarize yourself with the structure. If you don't have Access installed, the figures should give you a pretty good understanding of how the database is structured. To examine the structure of the database, follow these steps:

1.

Open retros_cycles_99300d2.mdb in Microsoft Access. In the Database window, notice that the database consists of three tables named tbCustomers, tbInventory, and tbPageData (see Figure 21.1).

Figure 21.1. The three tables that are located within the database.


Note

Depending on what version of Access you have installed, you might have to convert the Access database to your version. All the functionality that is discussed in this section applies to any version of Access.

2.

Select the tbPageData table and click the Design button. This table, shown in Figure 21.2, contains the content that is displayed on each of the web pages and information relating to its status, an image URL that is associated with the page, and a unique page ID that also serves as the primary key for the table. The page ID field is an autonumber field, which ensures that each record has a unique page ID.

Figure 21.2. The tbPageData table structure.


3.

Close the tbPageData table. In the Database window, double-click on the tbPageData table to open it in the data view. As you can see in Figure 21.3, several records in the database contain page content. Each of the records has a numeric page ID that is incremental in nature.

Figure 21.3. The tbPageData table data.


4.

Close the tbPageData table.

5.

In the Database window, select the tbCustomers table and click the Design button. This table, shown in Figure 21.4, contains information about Retro's Cycles customers. Again, the table has a primary key called customerid that is an autonumber field. The staff at Retro's Cycles can use this table to track customer information and purchases and to create mailing labels for periodic mailings.

Figure 21.4. The tbCustomers table structure.


6.

Close the tbCustomers table. In the Database window, double-click on the tbCustomers table to open it in the data view. As you can see in Figure 21.5, this table contains customer information. Again, each of the records has a numeric customerid that ensures it is unique.

Figure 21.5. The tbCustomers table data.


7.

Close the tbCustomers table.

8.

In the Database window, select the tbInventory table and click the Design button. This table, shown in Figure 21.6, contains information about the various motorcycles that are in stock. The primary key for this table is inventoryid.

Figure 21.6. The tbInventory table structure.


Tip

When developing a database for the web, primary keys are very important. A primary key ensures that the record you request via a web page is the only record that is returned. For instance, suppose you didn't have a primary key that identified each record as unique. If you created a query that said "Show me the record in the database where the last name is Smith," you might encounter problems if there is more than one Smith in the database. If, however, you assign a primary key to each record and you ask "Show me the record in the database where the customerid is 1223," then you know you're going to get the correct record because there will never be more than one record in the database with a customer ID of 1223.

9.

Close the tbInventory table. In the Database window, double-click on the tbInventory table to open it in the data view. As you can see in Figure 21.7, this table stores information relating to the motorcycles that are in inventory and their status.

Figure 21.7. The tbInventory table data.


10.

Close the tbCustomers table and close the database.

As you can see, this database structure is relatively simple and straightforward. Just because a database will be used on the web doesn't mean it has to be complex.



Special Edition Using Macromedia Studio 8
Special Edition Using Macromedia Studio 8
ISBN: 0789733854
EAN: 2147483647
Year: 2003
Pages: 337

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net