Datasheet
Chapter 1
24
Data Tier
The data tier consists mainly of the table definitions, relationships, and data items that constitute the
database itself, along with any pieces of code used for retrieving information from the database in its
natural format. In SQL Server, these would be SQL statements that are usually kept in stored procedures.
One of the hardest issues to address is where the data tier ends, and where the business tier begins. This
problem arises because it's quite easy to implement a lot of the functionality of the business logic
(business tier) in the database code (as stored procedures). Where the line should be drawn is largely
dependent upon the requirements of the application; whether rapid portability to other database server
products is a key concern, or whether high performance is preferable. If the former is more important,
then putting the majority of the functionality in the business tier is a preferable solution, and vice versa.
In the diagram above, there is a separate item called "data access code". This may simply represent the
use of ADO.NET, or it may be a separate layer of functionality that hides ADO.NET from the other
layers, preventing them from needing to know what type of data store(s) are being accessed.
Business Tier
The business tier of the application is where the majority of the application-specific functionality resides.
Usually, this functionality consists of calling multiple atomic actions (Read, Write, Delete
commands, etc.) in order to insulate the presentation tier from the complexities of the rules that the
application must conform to. This tier also generally contains any links necessary to the methods
exposed by third-party systems.
Contrary to popular object-oriented principles, any components created for the business tier of web
applications should be state les s – that is, they should make use of functions and procedures that take in
multiple parameters, rather than having properties that allow values to be set before making method
calls. In .NET, the business tier is often implemented using class libraries, as we'll discuss in more detail
in Chapter 10.
Presentation Tier
The presentation tier of the application is the only portion of the system that the end user gets to see,
whether it's a collection of web pages, the interface to an application such as Outlook, or even a
command prompt. This tier functions by making use of the functionality exposed to it via the business
tier – it can never access the database (or any other portion of the data tier) directly. In this way, it is
kept from being exposed to many of the details of how the application has been implemented, and can
focus on providing the most usable presentation of the information and options possible.
As stated above, the nature of data access with ADO.NET is such that on occasion, these guidelines are
not strictly adhered to. Indeed, we'll make use of this fact to abbreviate some of our early examples. But
as we progress through this book, you'll find this architecture cropping up again and again.