Creating the Database

The foundation for the store will be a database containing all the tables required for recording the customers, products, and transactions. Because databases are significantly more secure than flat files, you always want to use them for e-commerce applications so that the store and user information is safely kept away from curious eyes.

The first table you'll need—and the easiest to design—is for the customers (or users), detailed in Table 6.1.

Table 6.1. The users table keeps a list of every customer the site has. One update to the database would be to make the information in this table more international in scope by allowing for less Americentric addresses.
Table Users
Column Data Type
user_id number
username text
password ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide 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.