Using the Client Dataset in an N-Tiered Application
My last two articles demonstrated the use of the client dataset in a two-tier application. The two-tier architecture may be effective in some situations but in many circumstances it suffers from some serious drawbacks. This is where the concept of an n-tiered or multi-tiered architecture comes in.
Using the Client Dataset in an N-Tiered Application (Page 1 of 4 )
An n-tiered architecture or a three-tiered architecture is similar to the two-tiered architecture discussed in the previous article. Unlike the two-tiered architecture, however, an n-tiered architecture contains a middle tier that acts as an intermediary between the client application and the database server. Typically this architecture has three tiers -- user interface, business logic and data storage mechanism, each of which exists independently and usually on different platforms.
The middle tier itself may contain multiple layers or the architecture may include more than one data storage mechanism distributed over multiple computers. For this reason it is called an n-tiered architecture or a multi-tiered architecture. However, the objective of this article is to demonstrate how the client dataset along with a provider can be helpful in an n-tiered architecture and not discuss the architecture itself. So I will attempt to provide only a short overview of the architecture and how the client dataset can enhance its performance.
Two-Tiered vs. N-Tiered Architecture
A multi-tiered application is divided into three logical parts or tiers, as I have already mentioned: the data storage mechanism, business logic and user interface, which can be stored on different system.
In a two-tiered architecture, the business rules are included in the client application, which makes it more expensive as well as difficult to upgrade. It can be especially disadvantageous when the number of users is large. In such cases upgrading or modifying the business logic in a different client would require the upgrading of every client application. When the business logic is included in the client, even a slight variation in business rules can cause update errors that are difficult to reconcile.
In contrast, a multi-tiered application stores the business logic in the middle tier, which is centralized and is used by all client applications. This ensures that all client applications use a single set of business rules during an update, which can help avoid errors that arise when business rules reside in many client applications.
Apart from helping avoid logical errors, a centralized logic residing in the middle tier also helps reduce the size of the client application. Further, a two-tiered application requires a data access mechanism like BDE or ODBC to connect to the database server. We can make the database connection more flexible by using the client dataset and dataset provider, but the fact remains that a data access mechanism is still required. The client application would be required to install and manage the data access mechanism, making the application bulkier.
The client application in an n-tiered architecture can use communication protocols like HTTP, TCP/IP, DCOM and SOAP to connect to the server, thus removing the need to include data access mechanism information in the client application. This further reduces the size of the client application, because of which it is also called "a thin client."
A multi-tiered architecture also provides better security options. Since a client application interacts with the middle tier instead of the data source, you can isolate specific functionalities into the tier with different access restrictions. You can also add additional security layers or use security features supported by the communication protocol you are using.
When the number of users rises it puts strain on the network as well the machines, and the performance starts degrading. This can be avoided by distributing data processes over many machines. Load balancing can enhance performance significantly.
By using Delphi, you can create n-tiered applications faster and without a lot of effort. The application server and the client can be created separately and independently.