An Overview of the Dorknozzle Database
Now that you've become familiar with the inner workings of a database and you've effectively imported/restored the Dorknozzle .SQL file into your database of choice, open the DBMS you plan to use so that we can walk through the various tables contained in the Dorknozzle database.NOTEBecause of this book's size restrictions, we can not possibly walk through all the examples using all three database management systems. In the interests of simplicity and attainability, we'll walk through the examples using only Access. However, if you've imported/restored the .SQL script on your DBMS of choice, the overall structure for the Dorknozzle database should appear in your DBMS similar to the way it does in Access. At the very least, you can follow along and understand the inner pinnings and various tables contained in the Dorknozzle database using your DBMS of choice.As you can see from Figure 23.18, numerous tables exist for streamlining how users will interact with dynamic Dorknozzle content.
Figure 23.18. The Dorknozzle database contains numerous tables for streamlining dynamic Dorknozzle content.

- The Employees table
- The Departments table
- The CreditCards table
- The EmployeeStore table
- The Orders table
- Other tables
Remember, we can not possibly cover every aspect of the Dorknozzle web application. Instead, the rest of the book focuses on the Employee Store segment of the web application. As you'll see in the section "Other Tables," I've included numerous other tables so that you can practice the concepts presented in the rest of the book on your own. Let's get started!
The Employees Table
The Employees table is reserved for all users accessing and purchasing items from our Dorknozzle intranet store. The idea is that most tables in the database reference an employee to a certain extent. As you'll see later, other tables such as Orders, CreditCards, Departments, and HelpDesk have a relationship of some kind with an employee in the Employees table. For instance, an employee belongs to a department, an employee can have and ultimately store numerous credit cards, an employee can have multiple orders on file within the employee store, and lastly, an employee can have numerous help desk tickets submitted.Opening the database reveals the underlying design behind the Employees table, similar to Figure 23.19.
Figure 23.19. The Employees table contains numerous fields regarding employees' personal information.
[View full size image]

Field Name | Data Type | Key |
---|---|---|
CustomerID | AutoNumber | PK |
DepartmentID | Number | FK |
Name | Text | |
Username | Text | |
Password | Text | |
Text | ||
Phone | Text | |
Headshot | Text | |
BillingShippingAddress | Text | |
BillingShippingCity | Text | |
BillingShippingState | Text | |
BillingShippingZip | Text |
Figure 23.20. A one-to-many relationship exists between the Departments table and Employees table.

Figure 23.21. All Dorknozzle employees are listed, complete with their personal information, in the Employees table.
[View full size image]

The Departments Table
Considered a "lookup" table, the Departments table will rarely grow in size and almost never be modified. Lookup tables, such as the Departments table, serve one purpose, namely to separate potentially redundant data out of one table into a separate, easier-to-manage table. For a moment, assume that we don't have a Departments table and that instead, that information is located in the Employees table similar to the following table:
Name | Department | ... |
---|---|---|
Ada | Administration | ... |
Agnes | Administration | ... |
Cammy | Administration | ... |
Dave | Engineering | ... |
Ferris | Executive | ... |
Herb | Human Resources | ... |
Field Name | Data Type | Key |
---|---|---|
DepartmentID | AutoNumber | PK |
Department | Text |
Figure 23.22. The Departments table contains six departments that represent the six Dorknozzle departments.
[View full size image]

The Credit Cards Table
The next table to consider is the CreditCards table. Like the Departments table, redundant information would appear in the Employees table if we had to list the employee multiple times simply because they wanted to store more than one credit card. Instead of listing the employee twice, we simply create a separate table for credit cards. The relationship exists between the EmployeeID primary key in the Employees table and the EmployeeID foreign key in the CreditCards table. The CreditCards table exposes the following structure:
Field Name | Data Type | Key |
---|---|---|
CreditCardID | AutoNumber | PK |
EmployeeID | Number | FK |
Type | Text | |
Number | Text | |
Expiration | Date/Time |
Figure 23.23. Eight employees have one credit card on file. One employee has two credit cards on file.

The EmployeeStore table
The next, and possibly most important, table for us is the EmployeeStore table. We'll use the EmployeeStore table as a way to store all the items we'll be selling in the Dorknozzle employee store. If you've opened the EmployeeStore table in Design view, you'll notice that it has the following structure:
Field Name | Data Type | Key |
---|---|---|
ItemID | AutoNumber | PK |
ItemName | Text | |
ItemDescription | Memo | |
ImageURL | Text | |
Cost | Currency | |
Quantity | Number |
Figure 23.24. The Dorknozzle employee store carries numerous items ranging from shirts to golf balls.
[View full size image]

Figure 23.25. One item could have many orders.

The Orders Table
The Orders table will be used as a temporary repository to house items that customers are planning to purchase. This allows us to keep track of who's ordering what and also allows the shipping and receiving departments to process the order. Looking at the design view of the table reveals the following structure:
Field Name | Data Type | Key |
---|---|---|
OrderID | AutoNumber | PK |
EmployeeID | Number | FK |
ItemID | Number | FK |
Quantity | Number | |
DatePurchased | Date/Time | You'll notice that this table's structure is a bit different than the ones mentioned thus far. In this case, not only do we have a primary key, we have two foreign keys. The reason for this is simple. The Orders table will have a relationship with two tables as opposed to just one. Each employee could potentially have an order. Thus, we'd need a relationship between the EmployeeID primary key in the Employees table and the EmployeeID foreign key in the Orders table. Furthermore, as we stated in the previous section, each order will have a product association. Since this is the case, we'd need a relationship between the ItemID primary key in the EmployeeStore table and ItemID foreign key in the Orders table. The OrderID primary key in the Orders table simply acts as a unique identifier and is the order number that employees reference if they have questions about a particular order.Other TablesAs mentioned earlier in the chapter, we cannot possibly cover all aspects of the Dorknozzle web application throughout the course of this book. Instead, we'll cover basic functionality such as showing all records in the EmployeeStore table within the employee store web page. Furthermore, we'll allow users to select items from employee store and add them to their cart. Since it'll be difficult to cover all aspects of the Dorknozzle web application, what I have done is expose other tables within the Dorknozzle database so that once you grasp the basic concepts of selecting, inserting, modifying, and deleting, you can take those concepts and integrate the rest of the Dorknozzle functionality on your own. The tables I've exposed for you to work with on your own include the following:
If you look in the database, you'll notice that these tables are preceded with the letter x (as shown in Figure 23.26). The x stands for Xtra , and also serves as a way of keeping these tables grouped separately. Figure 23.26. All tables marked with thex are extra tables you can use to work with the Dorknozzle web application on your own time. |