Professional Documents
Culture Documents
sql server
When pages
are requested from the database, the
SQL Server Database Engine checks to
see if the
requested page s are already in the
cache.
ÚäÏãÇ ÊØáÈ ÇÍÏì ÇáÕÝÍÇÊ ÝÇä ÇáãÍÑß
íÊÇßÏ ÇæáÇ ãä æÌæÏåÇ Öãä ÇáÐÇßÑÉ
Client/Server Databases
In contrast to desktop databases (such as Microsoft Access), which make the clients do all
the work, client/server databases are like research librarians who handle a request by finding
the information and returning a photocopy. The actual reference materials never leave the
watchful eye of the research librarian.
In a client/server database, the database client prepares a SQL request—just a small text
message—and sends it to the database server, which in turn reads and processes the
request (see Figure 3-2). Inside the server, the security is checked, the indexes are searched,
the data is retrieved or manipulated, any server-side code is executed, and the final results
are sent back to the client.
All the database work is performed within the database server. If the client requests a data
set, the data set is prepared within the server and a copy of the data is sent to the client. The
actual data and indexes never leave the server. When the client requests an insert, update, or
delete operation, the server receives the SQL request and processes the request internally
The client/server–database model offers
several benefits over the desktop
database model:
Çä ÞæÇÚÏ ÇáãÚØíÇÊ ãÎÏã\ÒÈæä ÊÞæã
ÎÏãÇÊ ÇÖÇÝíÉ Úáì ÞæÇÚÏ ÇáÈíÇäÇÊ
ÇáãßÊÈíÉ
? Reliability is improved because the
data is not spread across the network
and several
applications. Only one process handles
the data.
ÇáæËæÞíÉ ÇÚáì áÇä ÇáãÚØíÇÊ ÛíÑ
ãæÒÚÉ Úáì ÇáÔÈßÉ æ ÇáÚÏíÏ ãä
ÇáÊØÈíÞÇÊ .ÝÇäå ÝÞØ äÙÇã ãÚÇáÌÉ æÇÍÏ
ÞÇÏÑ Úáì Ðáß
? Data integrity constraints and business
rules can be enforced at the server level,
resulting
in a more thorough implementation of
the rules.
ÇáÊßÇãá Ýí ÇáãÚØíÇÊ æ ÇáËæÇÈÊ æ
ÇáÞæÇÚÏ ÇáãÝÑæÖÉ Êßæä Úáì ãÓÊæì
ÇáãÎÏã æ ÇáÐí íÄÏí Çáì äÊÇÆÌ ÇßËÑ ÏÞÉ Ýí
Úãá ÇáäÙÇã
Client/Server Roles
In a client/server database configuration,
Ýí ÇáÞæÇÚÏ ãÎÏã ÒÈæä ÝÇä ÇáÇÚÏÇÏÇÊ
each side plays a specific role.
ÚäÏ ßá ØÑÝ ÊáÚÈ ÏæÑÇ ãÍÏÏÇ
If the roles are confused,
ÇÐÇ ßÇäÊ ÇáÞæÇÚÏ ÇáãÝÑæÖÉ ÛíÑ ÏÞíÞÉ
ÝÇä
then the performance and integrity of
the client/server database application
will suffer.
ÇáÇÏÇÁ æ ÇáÊßÇãá ÚäÏ ÇáÈÑäÇãÍ ÇáÎÇÕ
ÈÇáÞÇÚÏÉ Óíßæä ÓíÆ
N-Tier Design
Often, in a client/server application, more processes are involved besides the database client
and the database-server process. Middle tiers are often employed to handle connection handling,
connection pooling, and business logic.
A middle tier that handles connections is useful because multiple users can take advantage of
a few constantly open connections to the database server. This type of connection, however,
affects the way the database server can authenticate individual users. The database-security
plan will have to take this into account.
In a situation in which more than one server may be available, a common connection object
makes it easier to switch the users from Server A to Server B if Server A should go down. The
connection object becomes a single point that could automatically detect the situation and
switch to Server B. This type of solution works well with database mirroring.
Placing the business rules and data abstraction layer within a logical tier makes sense for
ease of development and maintenance. The question is where to physically locate this logical
tier. Some developers argue that the middle-tier logical layer should be in its own server, written
in .NET and separate from the database server. I disagree for two reasons:
? Business rules and database constraints should be enforced at the database server
physical level so they can never be bypassed by any user application or process.
? Coding the business rules at the database server level also gives the code faster access
to database lookups and improves performance.
The only downsides to coding the business rules within the server are that the programmer
must learn server-side programming and the database application is more difficult to port to
other database products.