IntroductionDesigning N-Tier client/server architecture is no less complex than developing two-tier architecture, however the N-Tier architecture, produces a far more flexible andscalable client/server environment. In two-tier architecture, the client and the server are the only layers. In this model, both the presentation layer and the middle layer arehandled by the client. N-Tier architecture has a presentation layer and three separatelayers - a business logic layer and a data access logic layer and a database layer. Thenext section discusses each of these layers in detail.
Different Layers of an N-Tier application
In a typical N-Tier environment, the client implements the presentation logic (thinclient). The business logic and data access logic are implemented on an applicationserver(s) and the data resides on database server(s). N-tier architecture is typicallythus defined by the following layers:
•
Presentation Layer: This is a front-end component, which is responsible for providing portable presentation logic. Since the client is freed of applicationlayer tasks, which eliminates the need for powerful client technology. The presentation logic layer consists of standard ASP.NET web forms, ASP pages,documents, and Windows Forms, etc. This layer works with the results/outputof the business logic layer and transforms the results into something usableand readable by the end user.
•
Business Logic Layer: Allows users to share and control business logic byisolating it from the other layers of the application. The business layer functions between the presentation layer and data access logic layers, sendingthe client's data requests to the database layer through the data access layer.
•
Data Access Logic Layer: Provides access to the database by executing a setof SQL statements or stored procedures. This is where you will write genericmethods to interface with your data. For example, you will write a method for creating and opening a SqlConnection object, create a SqlCommand object for executing a stored procedure, etc. As the name suggests, the data access logiclayer contains no business rules or data manipulation/transformation logic. Itis merely a reusable interface to the database.
•
Database Layer: Made up of a RDBMS database component such as SQLServer that provides the mechanism to store and retrieve data. Now that you have a general understanding of the different layers in a N-Tier application, let us move onto discuss the implementation of a N-Tier Web application.ImplementationIn this article, I will consider an example web site (that displays authors and author titles information) constructed using N-Tier principles and use the example Web siteto demonstrate the new features of ASP.NET 2.0 and SQL Server 2005. The sampleWeb site shown in this example is very simple and straightforward and will consist of only two pages: the first page will show the list of authors from the pubs database andthe second page will display the list of titles specific to a selected author.