Client Server Databases

Tamer Özsu and Patrice Valduriez : Principles of distributed database systems. Second Edition, Prentice Hall, Englewood Cliffs, New Jersey, 666 pages, 1999 ODBC - Tutorial : ADABAS ODBC Reference PERL - Reference

What You'll Learn This Week


Database System Architectures o Mainframe Architecture o Stand-Alone PC Architecture o File Sharing Architecture o Classic Client/Server Architecture o Three-Tier Client/Server Architecture Open Database Connectivity

Database System Architectures
y y

There are a number of database system architectures presently in use. One must examine several criteria: 1. Where do the data and DBMS reside? 2. Where are the application program executed (e.g., which CPU)? This may include the user interface. 3. Where are business rules (applications logic) enforced?

Traditional Mainframe Architecture
y y y y


Database (or files) resides on a mainframe computer. Applications are run on the same mainframe computer. e.g., COBOL programs or JCL scripts that access the database. Business rules are enforced in the applications running on the mainframe. Multiple users access the applications through simple terminals (e.g., IBM 3270 terminals or VT220 terminals) that have no processing power of their own. User interface is textmode screens. Example: DB2 database and COBOL application programs running on an IBM 390.

Applications run on the same PC and directly access the database. Business rules are enforced in the applications running on the PC. A single user accesses the applications.y y Advantages: o Excellent security and control over applications o High reliability . File Sharing Architecture .years of proven MF technology o Relatively low incremental cost per user (just add a terminal) Disadvantages: o Unable to effectively serve advanced user interfaces o Users unable to effectively manipulate data outside of standard applications Personal Computer .on the hard disk. the application is the DBMS.Stand-Alone Database y y y y Database (or files) reside on a PC . In such cases.

o Application communicates with DBMS server running on server machine through a Database Driver o Database driver (middleware) makes a connection to the DBMS server over a network. Each user runs a copy of the same application and accesses the same files. Possibly by file locking. PCs on the LAN map a drive letter (or volume name) on the file server. o Run one or more applications using the client machine's CPU. etc.g. Oracle Developer/2000. o Provides a Listening daemon that accepts connections from client machines and submits transactions to DBMS on behalf of the client machines. The application is also the DBMS. .Also. memory.y y y y y y y y y PCs are connected to a local area network (LAN). o Examples of clients: PCs with MS Windows operating system. Business rules are enforced in the applications . o Run a Database Management System that manages a database. Applications run on each PC on the LAN and access the same set of files on the file server. Server Machines: o Run own copy of an operating system. Example: Sharing MS Access files on a file server.prices falling Disadvantages: o Limited data sharing ability . the applications must handle concurrency control. Advantages: o (limited) Ability to share data among several users o Costs of storage spread out among users o Most components are now commodity items . A single file server stores a single copy of the database files.a few users at most Classic Client/Server Architecture y y Client machines: o Run own copy of an operating system. Forms and reports developed e.

Informix. Implementation is more complex because one needs to deal with middleware and the network. they can become unwieldy. 2. Entirely on the database server . o Oracle Server RDBMS running on a server. Stored procedures and triggers can help in this case. For IBM DB2: Client Application Enablers y Business rules may be enforced at: 1. Sybase.. called "Thin Clients" called "Fat Clients". The client application . RDBMS such as Oracle Server. DB2. . Additional burden on DBMS server to handle concurrency control. 2. o Establishes a connection from the client to the server and passes commands (e. 3. 1.g. Processing of the entire Database System is spread out over clients and server. A Mix of both. It is possible the network is not well suited for client/server communications and may become saturated. 2. PC with Windows NT operating system. Examples: o Oracle Server RDBMS running on a server. We can also call this a "Two Tier" or "Two Level" Client/Server Architecture Advantages of client/server: 0. Oracle Developer/2000 running on a client PC (connected with SQL*Net as the middleware). Disadvantages of client/server: 0. y Middleware: o Small portion of software that sits between client and server. 1.o Examples: Sun Sparc server running UNIX operating system. o See ODBC below. As more business rule logic is programmed into the client side applications. For Sybase: Sybase Open Client and Open Server. etc. Client Applications can take full advantage of advanced user interfaces such as Graphical User Interfaces. DBMS can achieve high performance because it is dedicated to processing transactions (not running applications). SQL) between them. o Examples: For Oracle: SQL*Net (or Net8) running on both client and server.

o Frees up DBMS server to efficiently process transactions Disadvantages: o System complexity .extremely complex to program and debug o Security issues Examples: o Oracle Server RDBMS running on a server. Another option is to aggregate transactions from multiple users with a Transaction Monitor Is "web friendly". The web browser becomes the user interface on the client. Sometimes called "application logic" server.Sybase-PowerSoft PowerBuilder running on a client PC. C++ application running on a UNIX workstation. o Oracle Server RDBMS running on a server. o Sybase Adaptive Server RDBMS running on a server. Advantages: o Centralize applications logic (one place to make changes) o Relieves clients from having to load up on applications logic (the "fat client" approach). Three-Tier Client Server y y y y y y y Same general situation as traditional client/server. MS Visual Basic application running on a client PC. . Difference is the enforcement of business rules (applications logic) is done in a "middle" layer.

BEA Tuxedo Transaction Processing System running on the "Middle tier" Sybase-PowerSoft PowerBuilder running on a client PC. for those of you from the UNIX world. o Oracle Server RDBMS running on a server. simply replace "PCs" with "UNIX Workstations" in the phrases above. o Sybase Adaptive Server RDBMS running on a server. Oracle Web Applications Server running on the "Middle tier" MS Internet Explorer (web browser) running on a client PC. Example Study : Sybase Client-Server Databases . Sybase Enterprise Application Server including the Sybase Jaguar CTS transaction processing system running on the "Middle tier" C++ application running on a UNIX workstation. o Microsoft SQL Server running on a Windows NT Server Microsoft Transaction Server (MTS) running on the Middle tier Microsoft Visual Basic application running on the client PC o IBM DB2 RDBMS running on the back end IBM CICS transaction management COBOL application BTW.

Validate the format of the information. In the mainframe processing model. such as data presentation and some data validation. y Client/Server Computing in the Database Environment In just the last few years. 3.Mainframe Computing Mainframe computing was the popular computing model before the client/server model became the widespread standard. 6. In mainframe computing. and those related to data access (steps 4 and 5). Accept the employee ID information. This off-loading of some tasks to clients with processing power improves performance because the server has more time for processing requests. y We can categorize these tasks as those related to data presentation (steps 1. Display the employee information on the terminal. the mainframe performs all processing and uses a "dumb" terminal (one with no processing power of its own) as a display unit. the server is heavily loaded because it performs all of the processing for every client (mainframes are computing monsters) In the client/server model. and 7). Get the employee information from the database. retrieving and displaying employee information on a terminal requires the following steps: 1. Display a form on the terminal into which a user can enter an employee ID 2. 7. The mainframe performs all of the steps because the terminal has no processing capability. the client/server model has gone from being the "new trend" in distributed (networked) computing to the "traditional model" for implementing distributed computing. Check the availability of the employee information. 4. 6. For example. Format the data for display on the users terminal. It divides processing into client applications and server applications that cooperate . 5. those related to data validation (steps 2 and 3). however. clients can perform some portion of the application processing.

This model specifies an application programming interface (API) layer which hides the intricacies of lower level software. The mainframe model requires three network events: in step 1 when the host must display the form on the screen. Consider the example given previously in the section ``Mainframe Computing''. The organization can save money by giving each employee the right amount of computing power needed to do their jobs. y Facilitates implementation of open systems because it is built around the International Standards Organization (ISO) Reference Model for networked accomplish tasks for the integrated application. y Reduces network traffic. y Allows an organization to use a variety of equipment to meet the needs of different applications and users because it supports a heterogeneous environment. in step 2 when the client sends the employee ID back to the host. The same example using the client/server model requires only two network events: for step 4 when the client sends the employee ID to the server and in step 6 when the server sends the employee information back to the client. making it easy to add new hardware and applications. Here are a few of the many advantages that client/server computing offers over the computing models that came before it: y Simplifies computer interactions for the user because smart clients implemented on desktop workstations present graphical user interfaces (GUIs) and multimedia applications. The cost of developing applications that use these types of interfaces for desktop workstations is less expensive than it is for the servers in mainframe computing. and in step 6 when the host sends the employee information back to the terminal and displays it. Programmers can get the processing power they need from workstations. and managers can work with computers that are best for creating schedules and other spreadsheets using desktop computers. which improves performance. Client/Server Nodes and Implementation .

returns the results. a daemon in UNIX) while a client application is most often a standard application program. FigureClientServer shows an example in which an application acts as both a client and a server. As a server. a file client. Relative Roles of Clients and Servers The terms "client" and "server" characterize relative roles rather than absolute roles. it stops execution. a client application calls API routines to send the requests to a server. the print server becomes a client if it has to ask a file server to send it a copy of the file it is going to print. Nodes are distinguished as client nodes and server nodes depending on their role. Sybase implements this capability with the Open Client and Open Server products. A server application is typically a continuous process (for example. in executing a print request. Although a single server node can accommodate more than one server application. they usually reside on different nodes. Architecture is fully functional when it allows clients to act as servers and servers to act as clients when necessary. system designers often implement server applications on dedicated server nodes because servers tend to be more specialized and require more processing and system resources than clients. detects them. however. Computers that run client applications may include many types of clients. During the course of its normal processing. the server runs continuously: it waits for requests. such as a directory client. There are often many nodes running the same client applications so that a single server node. Sybase applications that have both client and server functionality incorporate both Open Client and Open Server libraries. For example. it responds to requests from and returns results to the Open Client application. As a dedicated process.Client and server applications can reside on the same computer. FigureClientServer: An application can act as both client and server . serves several client nodes. and then waits for the next request. and a print client. For example. in a distributed computing environment. processes them. or node. As a client. When the client has finished its work. Client nodes tend to be generalized. it makes requests of the SQL Server and processes the results of those requests. such as a print server.

Examples of applications at this layer are: y y SQL access tools Application development tools (code generators) The second tier in a two-tier configuration offers direct service management and handles connections. The first tier in a two-tier configuration consists of presentation and application logic. Examples of these applications are: . RPCs allow users to open a connection to a single SQL Server. client applications connect directly to server applications and submit requests using Open Server applications or remote procedure calls (RPCs). It is built on a multithreaded architecture and ensures data integrity. A SQL Server application programmer can write custom event handlers to process client requests. The database client performs all the processing not associated with database access.Sybase Client/Server Database Environment In the Sybase client/server database environment. The Two-Tier Model In a two-tier configuration. The database server also maintains the data dictionary which defines the structure and contents of the database. and that SQL Server can then access data from many other servers. SQL Server runs all of the actual database management system¯it does all the processing associated with database access. concurrency control. It can include database servers and general purpose servers such as e-mail and print servers. The database server carries out the tasks initiated by client requests directed to the database. and the ability to recover from failures.

A component can be replaced by another that has the same specifications without rewriting or changing surrounding components. they create selfcontained software blocks or components. based on the component model. Figure TwoTier: Two-tier architecture The Three-Tier Model When developers design and implement software using a component model. Three-tier architecture. each with a specific function. The three-tier architecture allows the flexibility and freedom to replace components without affecting the rest of the system. This component model for software design also results in the ability to reuse components. such as a transaction processing monitor or an object-oriented environment. . is a popular design solution for large or complex server applications that run under some type of middleware. mail.y y y SQL Server applications that do not require global distributed transaction support Print. or compute servers built with Open Server Client messaging services built on event notification that use Open Server as a messaging hub FigureTwoTier shows SQL Server and Open Server applications in a two-tier configuration.

a special kind of . Many MIS developers find the three-tier construct essential. This tier might also validate user input.Advertissment ????? Sybase is the only database company that makes it easy to implement an independent application in the middle tier of a three-tier software architecture. such as SQL Server. FigureThreeTier illustrates the three-tier topology using Sybase products. supports global distributed transaction management. developers must integrate business rules either in the front-end tool or the back-end datastore. Business rules can be integrated with the back-end datastore by programming them in stored procedures or a trigger. y The second tier (or middle tier) can enforce business rules and referential integrity across all components of the third tier. it helps windowing systems display and manipulate data. This tier is implemented as an intermediate server. It consists of Sybase products from the "middleware" layer. Sybase IQ. This tier consists of Sybase products from the "tools" layer. and supports service mapping similar to a gateway application. This tier consists of Sybase products from the "database" layer. such as OmniCONNECT or Open Server. which are often database systems. Sybase MPP. The third tier is a back-end server that handles data integrity and local transaction branches. such as PowerBuilder or Optima++. It has local responsibility for controlled resources. and SQL Anywhere. Minimally. In environments that do not support a three-tier topology. y Three-tier architecture gives the application complete independence with respect to both the front-end tool and the back-end datastore and makes it easy to extend database functionality. Figure ThreeTier: A Sybase three-tier model The functionality of each tier is as follows: y The first tier supports presentation services on the client system.

update and manipulate data on a server A DBMS Driver is typically supplied by the individual DBMS vendor and contains routines to convert requests from the Driver Manager into commands the specific DBMS understands. updated. Open DataBase Connectivity (ODBC) y y y y y y y Middleware has historically been proprietary. How can a single client access multiple DBMS servers with minimal changes ? ODBC is middleware software that can connect a client to multiple servers from different vendors. Note also subtle differences in SQL and how it is implemented in various DBMS. The Driver Manager presents a uniform interface to all clients.stored procedure that automatically executes whenever data is inserted. so if business rules change. This consists of a set of function calls to query. . ODBC has two main portions that reside on the client: A Driver Manager and one or more DBMS drivers. Try this: Visit several DBMS vendor's web sites and see if they offer an ODBC driver that can be downloaded to your PC. Programming business rules in triggers results in dependence on the datastore. the database might need to be reoptimized. or deleted in the columns with which the trigger is associated.

time. Scrollable cursors. Provide a standard logon interface to the end user. ODBC includes a set of extensions that provide enhanced performance and increased power through the following features: y y y y y Data types such as date. A standard SQL grammar for scalar functions. ODBC example: Win32::ODBC and Perl script The following two tables will be used : Table 1: Sauces Field Name Type Length ProductID AutoNumber n/a Sequence / Primary key ProductName Text Quantity Number 25 Double in ounces Notes . timestamp. ODBC also defines an extended SQL grammar and set of extended functions to provide application developers with a standard way to exploit advanced capabilities of a DBMS. they need not write any additional code to check for specific capabilities of a driver. execute SQL statements. A standard way for application developers to find out what capabilities a driver and data source provides. If an application developer chooses only to use the core functionality. ODBC defines a standard SQL grammar and set of function calls that are based upon the SAG CLI specification. Use a standard SQL grammar defined by ODBC. Asynchronous execution. respectively. and retrieve results. Receive standard error messages. called the core grammar and core functions. and procedures. In addition to the above features. outer joins. Use a standard set of data types defined by ODBC. and binary. an application can: y y y y y Establish a connection with a data source.Example of the use of Open DataBase Connectivity (ODBC) What ODBC means to application developers ODBC was designed to allow application developers to decide between using the least common denominator of functionality across DBMSs or exploiting the individual capabilities of specific DBMSs. With core functionality.

Next we tell it to create a new ODBC object: my($db) = new Win32::ODBC("Article"). The first thing to do. in the order it was selected in the SQL statement. and 'bar' is the Password..Price PepperType Scoville Number Text Text Double 20 Long main type of pepper in sauce rating of heat content. where 'Article' is the Data Source Name.000 units! Table 2: State Field Name Type Length PID ProductID Sequence Number Long Notes Foreign Key into Sauces table . there are two actions. the script should look something like the following: use Win32::ODBC. use Win32::ODBC. is to tell the script that we want to use the module. 'foo' is the User ID. Next. as when using any Perl module. Data() and DataHash(). Scotch Bonnets (Habañero) = 2-300. and then the loop to fetch the data. my($db) = new Win32::ODBC('Article'). We'll use DataHash().Multi-key Primary key Number Integer Process ID . then the field order that the data comes back in is undefined. Jalapeño pepper = 3-4. .000 units. so using Data() might not make sense. } Inside the while loop we actually get the data. There are also two ways to get the fetched data. we write the SQL to extract the data (the capitalization is for stylistic reasons): $db->Sql("SELECT * FROM Sauces"). If you select all fields using the "*" wildcard. This creates an object ($db) which connects to the data source named 'Article'. one to fetch the row. as we did. The latter returns the data into a hash. let's write a simple script that extracts all the data from the database and writes them out in a table. we close the ODBC handle before the end of the program. The former returns the data into an array. one row at a time: while ($db->FetchRow()) { . If we had a user name and password associated with this data source. in the form '$hash{FieldName} = DataValue'. Putting it all together. and one to get the data that was fetched. Finally. In Win32::ODBC. we could supply them all using an ODBC connect string: my($db) = new Win32::ODBC("dsn=Article.Multi-key Primary key Number Integer Multi-key Primary key To get started. uid=foo.. pwd=bar").

" <TD>\$$data{'Price'}". Data Sources Sometimes you don't know ahead of time which database you need to connect to.. my(%dsn. foreach $key (sort keys %dsn) { print HTML "<OPTION>$key\n" if $dsn{$key} =~ /Oracle/. } .. and then rollback or commit depending upon program flow: $db->SetConnectOption('SQL_AUTOCOMMIT'. Sometime after connecting (usually immediately after. you can query it to see if it can handle a specific ODBC API function. } Once you have connected to a driver. $key) = Win32::ODBC::DataSources(). " <TD>$data{'Quantity'} ounces". 'SQL_AUTOCOMMIT_OFF'). while ($db->FetchRow()) { my(%data) = $db->DataHash(). This will produce a box with all of the data sources listed. if ($fatal_error) { $db->Transact('SQL_ROLLBACK'). " <TD>$data{'Scoville'} Scoville Units". so you could filter them: my(%dsn.. . with commits and rollbacks (see Data Sources to find out how to determine if your driver supports this). $db->SetConnectOption('SQL_AUTOCOMMIT'.. " <TD>$data{'PepperType'}". The value of the returned hash contains the name of the driver. die "Error . print print print print print } $db->Close(). my($transOK) = $data{$db->SQL_API_SQLTRANSAC}. $db->Transact('SQL_COMMIT').rolling back\n". } print HTML "</SELECT>\n". foreach $key (sort keys %dsn) { print HTML "<OPTION>$key\n".$db->Sql("SELECT * FROM Sauces"). $key) = Win32::ODBC::DataSources(). Transactions Some ODBC drivers support transactions. HTML HTML HTML HTML HTML "<TR><TD>$data{'ProductName'}". But suppose you knew you only wanted Oracle databases. . but it depends on your logic flow) you can set the AutoCommit option off. You can query the ODBC Manager and get a list: print HTML "<SELECT NAME="DataSources" SIZE=1>\n". 'SQL_AUTOCOMMIT_OFF') if ($transOK). such as transactions: my(%data) = $db->GetFunctions($db->SQL_API_SQLTRANSACT).

High-level ODBC y Look in the Control Panel (shown here. my($db_name) = $db->GetInfo($db->SQL_DBMS_NAME). from Windows 95): y y Open up the 32bit ODBC icon.or you could query the connection for things like the database name and version: my($db_ver) = $db->GetInfo($db->SQL_DBMS_VER). This is called the ODBC Data Source Administrator or ODBC Administrator for short. Click on the ODBC Drivers tab to see which drivers are installed: .

(DSN = "Data Source Name". MS Excel. Clicking on the User DSN tab shows those data sources that have been defined for this user. MS Visual FoxPro Borland dBase and Paradox Text files Oracle 8 MS SQL Server Sybase System 11 To add more drivers. the specific database table or file that will be used y . MS Foxpro. The ODBC driver will then appear on this list. download or install the ODBC driver from the database manufacturer. see before) A user data source simply gives a name to a configuration that includes: The specific ODBC driver to be used In some cases. we have ODBC drivers for IBM DB2 Microsoft Access.y In the above example.

If necessary. a username and password required to gain access to the database FInally. any other options the particular ODBC driver requires .

Sign up to vote on this title
UsefulNot useful