The requirements for eCommerce call for the application to be Web-based with an HTML front end compatible with a variety of browsers. The application will require a database to store user transactions (such as items ordered by the user) and to list items available through the electronic store.
The application must also include a middle tier—the Web server and scripts executed by the server—to process requests sent from Web browsers. A Web browser will send HTTP requests to the middle tier. The middle tier will then retrieve information stored in the database, process it appropriately, and send a reply back to the client.
Database Alternatives
An electronic database is utilized to store data associated with eCommerce applications. Such information might include information pertaining to registered users, goods and services, and records of transactions effected by visitors to the site.
We have two alternatives for storing this information:
- Employing flat files to store the data in text files.
- Utilizing a relational database system such as MySQL, Oracle or Sybase.
Flat files are strongly discouraged because they require excessive development. Such development might entail designing layouts for data storage in text files so that data may be manipulated, and designing simple interfaces to access data stored in these files.
This functionality is readily available in relational databases. We have selected MySQL for our demonstration eCommerce application because:
- MySQL is an open source relational database, and, thus, has a significant cost advantage over other commercially available relational database management systems.
- MySQL is highly scalable and is not difficult to administer. A trained database administrator is not required to manage MySQL installation, and management is relatively simple.
- MySQL supports client APIs for a variety of programming languages (such as Perl, C and PHP), and client programs that access database information may be developed with such APIs. We are, therefore, provided more programming language choices for implementing the middle tier.
Middle Tier Options
The middle tier produces run time HTML output by generating data in the middle tier itself or by retrieving data from the database. For example, in order to display a list of items offered on a site, the middle tier would return the pertinent information from the database, manipulate it appropriately, then dynamically generate an HTML document that displays the items of interest.
Options for implementing the middle tier include:
- CGI (Common Gateway Interface) programs written in Perl or C. These CGI programs access the database using the database language APIs.
- Servlets on the middle tier. Servlets access the database by employing Java database APIs and the JDBC database driver. (JDBC drivers are available for most relational database management systems.)
- Server-side scripting languages such as PHP or Perl. These languages support APIs for nearly all relational database management systems.
PHP was chosen for implementing the middle tier functionality in our demonstrative eCommerce application because:
- PHP support is available on a wide variety of platforms (such as Linux and Windows NT) and an assortment of Web servers (such as Apache and IIS). Thus, we have a choice of platforms and Web servers for hosting the middle tier.
- Performance is one of the implicit requirements for shopping cart applications, and scripting solutions provided by PHP are preferred over servlets and CGI programs.
- PHP supports APIs for accessing a large set of databases. It also supports features such as database persistent connections and simple APIs for cookies. (Cookies will be used extensively in the middle tier of the shopping cart application.)