This chapter contains product reviews, transactions in the application, ACID test, literature overview, conclusion and starts the coding parts of the complete and functional eCommerce website e-shopping project.
Product Reviews
At this point, we have a complete and functional e-commerce web site. However, this doesn’t stop us from adding even more features to make it more useful and pleasant for visitors. By adding a product reviews system to your web site, you can increase the chances that visitors will return to your site, either to write a review for a product they bought or to see what other people think about that product.
A review system can also help you learn your customers’ tastes, which enable you to improve the product recommendations and even make changes in the web site or the structure of the product catalog based on customer feedback. To make things easy for both the customer and us, we’ll add the list of product reviews and the form to add a new product review to the product details pages. The form to add a new product will show up for only registered users because we decided not to allow anonymous reviews (however, you can easily change this if you like). We’ll create the code for this new feature in the usual way, starting from the database and finishing with the user interface.
8.8. Transactions in the Application
A transaction is a group of database commands that are treated as a single unit.
The transaction must pass what is known as the ACID test:
Atomic: All operations in the transaction are executed properly or none. In other words, they make up a single unit of work. For example, if a customer moves and a transaction is used to reflect that change in the database, all parts of the address (street, city, state, etc) must be changed as an atomic action, rather than changing street, then city, then state, and so on.
Consistent : The execution of a single transaction preserves the consistency of the database. All the relationships between data in a database are maintained correctly. For example, if customer information uses a tax rate from a state tax table, the state entered for the customer must exist in the state tax table.
Isolation: Each transaction is unaware of the other transactions occurring concurrently. Changes made by other clients cannot affect the current changes. For example, if two data entry operators try to make a change to the same customer at the same time, one of two things occurs: either one operator’s changes are accepted and the other is notified that the changes were not made, or both operators are notified that their changes were not made. In either case, the customer data is not left in an indeterminate state.
Durability: Changes the transaction has performed persist in the database. Once a change is made, it is permanent. If a system error or power failure occurs before a set of commands is complete, those commands are undone and the data is restored to its original state once the system begins running again.
Transaction processing is particularly important for Web applications that use data access, since Web applications are distributed among many different clients. In a Web application, databases are a shared resource, and having many different clients distributed over a wide area can present these key problems:
Contention for resources. Several clients might try to change the same record at the same time. This problem gets worse the more clients you have.
Unexpected failures. The Internet is not the most reliable network, even if your Web application and Web server are 100 percent reliable. Clients can be unexpectedly disconnected by their service providers, by their modems, or by power failures.
Web application life cycle. Web applications do not follow the same life cycle as Windows applications Web forms live for only an instant, and a client can leave your application at any point by simply typing a new address in their browser.
Transaction processing follows these steps:
1. Begin a transaction.
2. Process database commands.
3. Check for errors.
4. If errors occurred, restore the database to its state at the beginning of the transaction. If no errors occurred, commit the transaction to the database.
Suppose two users try to add the same book to the shopping cart and try to place an order at the exact same time. An update should be done to the Books table after the order is placed, but if only the latest transaction is noted down, the book quantity will differ in the real world. This situation has to be handled as in a Transaction. As detailed earlier, a transaction is any operation or set of operations that succeeds or fails as a logical unit. That is, either both the updates are not done, or both the updates are done consecutively.
Transactions are normally managed by declaring boundaries around a set of operations. Operations that execute in the context of the transaction boundary then succeed or fail as a unit. For ASP.NET, the transaction boundary is the execution of a single request to a page, which might contain nested components that participate in the same transaction. While the page is executing, if an operation on the page itself or a nested component in the same transaction fails, it can call ContextUtil.SetAbort. This is then picked up by the current transaction context, the entire transaction fails, and any operations that were already completed are undone. If nothing fails, the transaction is committed.
2.1 Literature Review
Electronic Commerce (e-commerce) applications support the interaction between different parties participating in a commerce transaction via the network, as well as the management of the data involved in the process.
The increasing importance of e-commerce is apparent in the study conducted by researchers at the GVU (Graphics, Visualization, and Usability) Center at the Georgia Institute of Technology. In their summary of the findings from the eighth survey, the researchers report that e-commerce is taking off both in terms of the number of users shopping as well as the total amount people are spending via Internet based transactions. Over three quarters of the 10,000 respondents report having purchased items online. The most cited reason for using the web for personal shopping was convenience (65%), followed by availability of vendor information (60%), no pressure from salesperson (55%) and saving time (53%).
Although the issue of security remains the primary reasons why more people do not purchase items online, the GVA survey also indicates that faith in the security of ecommerce is increasing. As more people gain confidence in current encryption technologies, more and more users can be expected to frequently purchase items online
Another important factor in the design of an e-commerce site is feedback. The interactive cycle between a user and a web site is not complete until the web site responds to a command entered by the user. According to Norman, “feedback–sending back to the user information about what action has actually been done, what result has been accomplished–is a well known concept in the science of control and information theory. Imagine trying to talk to someone when you cannot even hear your own voice, or trying to draw a picture with a pencil that leaves no mark: there would be no feedback”.
Web site feedback often consists of a change in the visual or verbal information presented to the user. Simple examples include highlighting a selection made by the user or filling a field on a form based on a user’s selection from a pull-down list. Another example is using the sound of a cash register to confirm that a product has been added to an electronic shopping cart.
Completed orders should be acknowledged quickly. This may be done with an acknowledgment or fulfillment page. The amount of time it takes to generate and download this page, however, is a source of irritation for many e-commerce users. Users are quick to attribute meaning to events. A blank page, or what a user perceives to be “a long time” to receive an acknowledgment, may be interpreted as “there must be something wrong with the order.” If generating an acknowledgment may take longer than what may be reasonably expected by the user, then the design should include intermediate feedback to the user indicating the progress being made toward acknowledgment or fulfillment.
Finally, feedback should not distract the user. Actions and reactions made by the web site should be meaningful. Feedback should not draw the user’s attention away from the important tasks of gathering information, selecting products, and placing orders.
10. Conclusion
The Internet has become a major resource in modern business, thus electronic shopping has gained significance not only from the entrepreneur’s but also from the customer’s point of view. For the entrepreneur, electronic shopping generates new business opportunities and for the customer, it makes comparative shopping possible. As per the survey, most consumers of online stores are impulsive and usually make a decision to stay on a site within the first few seconds. “Website design is like a shop interior. If the shop looks poor or like hundreds of other shops the customer is most likely to skip to the other side”[16]. Hence we have designed the project to provide the user with easy navigation, retrieval of data and necessary feedback as much as possible.
In this project, the user is provided with an e-commerce web site that can be used to buy books online. To implement this as a web application we used ASP.NET as Technology. ASP.NET has several advantages such as enhanced performance, scalability, built-in security and simplicity. To build any web application using ASP.NET we need a programming language such as C#, VB.NET, J# and so on. C# was the language used to build this application. For the client browser to connect to the ASP.NET engine we used Microsoft’s Internet Information Services (IIS) as the Web Server.
ASP.NET uses ADO.NET to interact with the database as it provides in-memory caching that eliminates the need to contact the database server frequently and it can easily deploy and maintain an ASP.NET application. MySQL was used as the back-end database since it is one of the most popular open-source databases, and it provides fast data access, easy installation, and simplicity.
A good shopping cart design must be accompanied by a user-friendly shopping cart application logic. It should be convenient for the customer to view the contents of their cart and to be able to remove or add items to their cart. The shopping cart application described in this project provides a number of features that are designed to make the customer more comfortable.
This project helps in understanding the creation of an interactive web page and the technologies used to implement it. The design of the project which includes the Data Model and Process Model illustrates how the database is built with different tables, how the data is accessed and processed from the tables. The building of the project has given me a precise knowledge about how ASP.NET is used to develop a website, how it connects to the database to access the data and how the data and web pages are modified to provide the user with a shopping cart application.
An e-commerce organization can create data-based Web pages by using server-side and client-side processing technologies or a hybrid of the two. With server-side processing, the Web server receives the dynamic Web page request, performs all processing necessary to create the page, and then sends it to the client for display in the client’s browser. Client-side processing is done on the client workstation by having the client browser execute a program that interacts directly with the database.
6. Connection with the database
Opening a connection to the MySQL database from PHP is easy. Just use the mysql_connect() function like this
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');$dbname = 'db_ecommerce';
mysql_select_db($dbname);
?>
$dbhost is the name of the MySQL server. When your web server is on the same machine with the MySQL server you can use localhost or 127.0.0.1 as the value of $dbhost. The $dbuser and $dbpass are valid MySQL user name and password. For adding a user to MySQL visit this page: MySQL Tutorial
Don’t forget to select a database using mysql_select_db() after connecting to MySQL. If no database selected your query to select or update a table will not work.
8. The Shopping Cart Application
The objective of this application is to provide the user with an online website where they can buy things from the comfort of their home. A shopping cart is used for the purpose. The user can select the desired items, place them in the shopping cart and purchase them using a Credit Card. The user’s order will be shipped according to the type of shipping selected at the time of placing the order.