5.2. Creating the Shopping Cart Database

The shopping cart database stores information about the products and about the orders. It stores the catalog of products. It stores general information about the order, such as the customers' names and addresses, and the items selected for each order and when the order was submitted. The application in this chapter sells products from the Furniture Shop catalog, which we describe in Chapter 4 in this minibook.

5.2.1. Designing the shopping cart database

The sample application in this chapter uses a database named OnlineShop. The database contains three tables, described in the following sections. One table (the Furniture table) is the catalog of products. A second table (the CustomerOrder table) stores information general to the order, such as name and address, order number, and so on. The third table (the OrderItem table) stores a row for each item ordered, linked to the first table by the order number.

The catalog can be in a separate database. The catalog database might include other tables related to the products, such as an inventory table. In this example, the catalog is in the same database as the order information to simplify the example.

5.2.1.1. The CustomerOrder table

The table named CustomerOrder contains information related to the order as a whole, as shown in Table 5-1.

You can't name tables with MySQL reserved words. This ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.