The Database Structure
For simplicity, a Microsoft Access database is used as the example in this chapter. For deployment, however, you are encouraged to port it in a more scalable and powerful database. The Access database file is located in the \db directory under the application's WEB-INF directory. You use four tables for this project: Categories, Products, Orders, and OrderDetails. The structure of each table is given next.
The Categories Table
The Categories table is used to store product categories. It is a simple table whose design is given in Table 18.1.
Table 18.1 The Structure of the Categories Table
Column Name |
Data Type |
CategoryId |
AutoNumber |
Category |
Text |
The Products Table
The Products table is used to store the details of every product sold. Its structure is presented in Table 18.2. Note that the table uses a CategoryId column to categorize the products.
Table 18.2 The Structure of the Products Table
Column Name |
Data Type |
ProductId |
AutoNumber |
CategoryId |
Number |
Name |
Text |
Description |
Text |
Price |
Number |
The Orders Table
The Orders table holds order information, including the delivery address, the credit card details, and the contact name. A unique identifier is used for each order, which is used to link to all shopping items in the OrderDetails table.
The structure of the Orders table is given in Table 18.3.
Table 18.3 The Structure of the Orders Table
Column Name |
Data Type |
OrderId |
Number |
ContactName |
Text |
DeliveryAddress |
Text |
CCName |
Text |
CCNumber |
Text |
CCExpiryDate |
Text |
The OrderDetails Table
The OrderDetails table is used to store all shopping items for each order. Its structure is given in Table 18.4.
Table 18.4 The Structure of the OrderDetails Table
Column Name |
Data Type |
Id |
AutoNumber |
OrderId |
Number |
ProductId |
Number |
Quantity |
Number |
Price |
Number |