* REAL WORLD E-Commerce Applications
Many e-commerce applications are designed
to handle thousands of online users and numerous concurrent transactions.
Companies that use these applications often run them on multiple systems.
Using a single computer system can be unsuitable for many reasons, including the following:
* The capacity of one system is insufficient.
Any computer system has limitations.
The number of transactions performed by an e-commerce application
might exceed the capacity of a single system.
* Business logic.
It might make sense from a business perspective to put different functions on different systems.
For example,
a company might want user information on one system and product information on another system.
* Outsourcing is used.
E-commerce functions are sometimes outsourced.
For example, a company could hire another company to perform billing.
When multiple systems (or multiple databases on the same system) are used,
distributed transactions are initiated to access information in the systems (or databases).
If MS DTC is not used, atomicity might be impossible to guarantee.
Let's look at an e-commerce transaction that uses distributed transactions.
In this example, the customer wants to use her credit card to purchase a product,
a new water bowl for her dog, from an imaginary company named Piercetronics.
Let's deconstruct this transaction into its major components.
NOTE
---------
There are many ways to perform e-commerce transactions.
The method described in the following list is not necessarily the best way of performing e-commerce transactions but is rather a simple method that was chosen to make this example easier to understand.
1. The customer establishes a connection to Piercetronic's Web server.
At this point, she is most likely looking at static Web pages and is not actually connecting to the database.
2. She browses around for a while and finally finds the water bowl that she wants to purchase.
She then puts it into her shopping cart.
3. Placing the item into the shopping cart will require two database operations to be carried out:
a. A lookup must be performed to find out whether the customer is a return customer or a new customer.
If she is a return customer, her account ID is retrieved.
(Some applications do this at purchase time.)
b. The item is inserted into a shopping-cart table.
4. When the customer indicates she is ready to check out,
a database transaction or set of transactions begins in order to perform the following operations:
a. The shopping-cart table is read in order to find the item that the customer is purchasing.
b. The order table has a new row inserted that contains the order.
c. The customer database is accessed to update the customer's account so that she can be billed for this order.
Because in this example customer account information is stored in a database
separate from the database containing the order table,
the transaction is escalated to a distributed transaction.
d. The record in the shopping-cart table is deleted at this point.
(However, some applications purge the shopping-cart table at a later time, in a batch operation.)
e. Once both the account table and the order table are updated, the transaction can be committed.
Thus, the distributed transaction is finished.
5. At a later time, employees at Piercetronic's warehouse will access the database
and put together the order for shipment.
More specifically, the following transactions occur:
a. The order table is queried and the order is retrieved.
b. The item is pulled off a shelf and put in a box for shipment.
c. Piercetronic's system connects to a credit card processor to charge the customer's card.
This transaction is a distributed transaction because the charge is recorded locally as well.
(Some applications bill the customer's card when he or she checks out,
but this is not the typical procedure, as getting credit card approval usually takes longer than the transaction can be held open.)
d. In a distributed transaction, the order table is updated
and the database containing account information is updated to reflect the shipment.
6. The package arrives and the customer's dog has a new water dish to drink from.
If any of the components had failed during these distributed transactions
and if Piercetronics had not been using MS DTC,
which enables two-phase commits, several problems could have occurred, including the following:
* The customer's credit card could have been charged for an item that she never received.
* Her order could have been placed and shipped without a charge to her credit card.
* The order table could have been updated to indicate the product was shipped, when the shipping never occurred.
So you can see the necessity of making sure
that either all systems are updated or no systems are updated in a distributed transaction.
Without the coordination of these transactions,
the databases could become inconsistent and several problems could occur.
Source: Microsoft SQL Server 2000 Administrator's Companion Book