anagement Systems
Chapter 11
Distributed Databases
Jerry Post
Copyright © 2001Distributed Databases
~> Definition
«> Advantages / Uses
<> Problems / Complications
“> Client-Server / SQL Server
<> Microsoft Access
SELECT Sales
FROM Britain.Sales
UNION
‘SELECT Sales
FROM France.Sales
UNION
SELECT Sales
FROM lItaly.Sales
Germany
FranceDistributed Database Definition
<> Multiple independent databases
+ Each DBMS is a complete
DBMS (engine, queries,
locking, transactinos, etc.)
+ Usually on different machines.
+ Usually in different locations.
~ Connected by a network.
«> Might be different environments
+ Hardware
+ Operating System
+ DBMS Software
Database
Zeus
England
as “here
United StatesDistributed Database Rules
> C.J. Date + Distributed query processing.
~ Rule 0: Transparency: the + Distributed transaction
user should not know or care management.
that the database is distributed. + Hardware independence.
+ Local autonomy. + Operating system independence.
+ No reliance on a central site. + Network independence.
+ Continuous operation. + DBMS independence.
+ Location independence.
+ Fragmentation independence
(physical storage).
+ Replication independence.Distributed Features
«> Each database can continue to run even if portion fails.
«> Data and hardware can be moved without affecting
operations or users.
+ Expanding operations.
+ Performance issues.
<> System expansion and upgrades.
+ Add new section without affecting others.
+ Upgrade hardware, network and DBMS.Advantages and Applications ,,..
«> Business operations are
often distributed
+ Work and data are
segmented by department.
+ Work and data are
segmented by geographical
location.
<> Improved performance
+ Most updates and queries
are performed locally.
+ Maintain local control and
responsibility over data.
~» Can still combine data
across the system. 1
“> Scalability and expansion
+ Add on, not replacement.
transactions
’ future
Nexpansion
=
6Creating a Distributed Database
~ Design administration plan.
~ Choose hardware and DBMS vendor,
and network.
~ Set up network and DBMS
connections.
~ Choose locations for data.
~ Choose replication strategy.
~> Create backup plan and strategy.
~ Create local views and synonyms.
~ Perform stress test: loads and failures.Distributed Query Processing
«> Networks are slow
+ Drives: 10 - 20 MB per sec.
+ LANs: 1 - 10 MB per sec.
+ WANs: 0.01 - 5 MB per sec.
+ Faster is possible but expensive!
«> Goal is to minimize transmissions.
+ Each system must be capable of
evaluating queries--preferably SQL.
+ Results depend heavily on how the
system joins tables.
Disk driveDistributed Query Processing
~ Example
+ NY: Customers: 1 M rows a
Customers(C#, ...)
+ LA: Production: 10 M rows 1,000,000
+ Chicago: Sales: 20 M rows C# list from
+ Query: List customers who ino aie: 6
bought blue products on 1-Mar-01 Sales(SH OF, Sdate) | Customer
+ Bad idea #1 20,000,000 data
4 Transfer all rows to Chicago Saleltem(S#, Pit...)
4 Then JOIN and select. SUBD 000
+ Better idea #2 (probably) P# sold on
4 Transfer blue products from LA 1-Mar-01
to Chicago Blue P#
+ Better idea #3 sold on
1-Mar-01
4 Get sale items on 1-Mar-01
4 Get blue products from LA _ | Products(P#, Color...)
4 Send C# to NY 2,000,000Data Replication
~> Goals
+ Minimize transmissions
+ Improve performance
+ Support heavy multiuser
access.
«> Problems
+ Updating copies
4 Bulk transmissions
4 Site unavailable
+ Concurrency
4 Easier for two people to
change the same data at
the same time.
~ Decision support systems.
~ Data warehouse.
France: Customers|
& Sales
Spain: Customers
& Sales
Britain: Customers
& Sales
France: Customers)
& Sales
Spain: Customers.
& Sales
Market research &
data corrections.
Periodic
updates
2
a
Update data.Concurrency and Locks
<> Each DBMS must maintain
lock facility.
«> To update, each DBMS must
utilize and recognize other
lock mechanisms and return
codes.
«> Each DBMS must have a
deadlock resolution protocol
that recognizes the
distributed databases.
+ Random wait.
DBMS #1
Accounts
8898
+ Optimistic updates.
+ Two-phase commit.
Jones
Transadtion B
Waiting
3561 ‘LockedTransactions & Two-Phase Commit
<> Two (or more) separate lock
managers.
«> DBMS initiating update
serves as the coordinator.
<> Two phases
+ Coordinator sends message
and data to all machines to
“get ready.”
+ Local machines save data in
logs, verify update status
and return message.
+ Ifall locals report OK, then
coordinator writes log and
instructs others to proceed.
If any fail, it sends Rollback
message.
Database 1
Initiate Transaction
1, Prepare to commit.
2. Commit
Database 2
Lock tables.
Save log."
Update all tables!Distributed Design Questions
juestion Concurrent Replication
What level of data consistency is needed? High Low = Medium
‘How expensive is storage? Medium-High | Low
+4 What are the shared access requirements? Global Local
How often are the tables updated? Often Seldom
‘Required speed of updates (transactions)? Fast. Slow
=| How important are predictable transaction times? _| Hig Low
DBMS support for concurrency and locking? ‘Good — Excellent_| Poor
Can shared access be avoided? No YesDistributed Databases In Oracle
~ Database Links Schema.Table@Location
+ Full database names.
[email protected]
+ CONNECT command. Server 2
~ Linking through synonyms. database \
+ CREATE SYNONYM ... ae 1
+ Central control over permissions. y' Procedure:
«> Linking through Views/queries. Employee
+ CREATE VIEWAS ... WHERE ...
+ Can assign local permissions. /
«> Linking through stored procedures.
+ DELETE ... View MJ User can only
+ Strong control over actions. Ji ; ~7 run procedure.
user No other access.
permissionsClient-Server
Server
Clients Clients
Shared
Database
Front-end
User InterfaceLAN File Server
File Server
«> Not a distributed database.
+ Data file stored on server.
+ Server is passive, appears
as giant disk drive to PC.
+ PC processes all data. All data from all tables are
+ Retrieves all needed data | read by PC, which performs
across the network. JOIN and WHERE test. If
: available, reads index first.
<> Performance improvements.
+ Indexes are crucial. !
+ Store some data on each a
PC (replication). SELECT Name, SaleDate
+ Store applications on PC _| FROM Customer INNER JOIN Sales
(graphics & forms). ON Customer.C# = Sales.C#
WHERE SaleDate BETWEEN #1-Mar-97#
+ Convert to SQL-Server AND #9-Mar-97#;
16LAN File Server: Slow
File Server
MyFile.mdb
CustID Name ...
15 Jenkins...
Forms||425 Juarez ...
Application
and query
DBMS =
software One row at a time
transferred. transferred, until
SELECT™ all rows are examined.
FROM Customer
WHEREClient-Server Databases
File Server
“> One machine machine is
dominant (server) and
handles data for many
clients.
~» Client machines handle
front-end tasks and small
data tables that are not
shared.
Send SQL
statement.
| applicationMicrosoft Access
«> Access is a client-side database.
+ In file server environment.
+ Asaclient to a database server.
~> Attach or Link to other databases.
+ Link to an Access database is file server.
+ Link through ODBC is database server.
~» ODBC: Open DataBase Connectivity
«> Pass-Through QueriesOpen Database Connectivity: ODBC
Server Computer
~ Microsoft connectivity standard. poe
+ Most DBMS companies
provide drivers. i
+ SQL Server, Oracle, Ingres, ODBC driver
etc. i —- z
+ Driver is installed on PC and 2 >
Server. & &
~ ODBC handles: i
+ Login to database. ODBC driver
+ Send query. | Link Tables
+ Interpret result codes. -
+ Exchange data. Access
Client ComputerODBC Basics
~ Set the connection string.
+ Datatype: odbc
+ DSN: data source name holds linkage data--built with Windows Control
Panel or RegisterDatabase.
+ uid: login Username
+ pwd: login Password
+ database: full database name on remote system.
21ADO and Direct Connections
Server Computer
The Database vendor peas
provides its own data :
transport (e.g,. Oracle or
SQL Server) installed on \ + Poems transport
the server and the client. ee
oO 4
ADO provides a driver that w@ 3
connects your application to a &
the transport services.
DBMS transport
ODBC can serve as the
data transport if nothing ADO
else is available vistaEasig
application
Client Computer
22Three-Tier Client-Server
; ~> Server Databases
~ Client front-end
«> Middle
+ Locate databases
+ Business rules
+ Program code
Legacy applications.
Database links.
Business rules.
Program code.
Front-end.
y) Database
Middleware
Application. 2p
User Interface.
Client S
25The Internet as Client-Server
information
Internet
Router
lent) (oes
Browser
Web Server
http://server.location/page Pintpaces
Forms
GraphicsHTML Limited Clients
Codestin Search App
atASP Code Structure
Connect to the Database ®
Create the SQL
Connect to the Database/Recordset
Loop through the Recordset Note: Access will create
Get a Field the basic structure.
Display it Export a query as asp.
Move to the next row Then edit the file.
End Loop
Set objConn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB. Recordset”)
sql =" SELECT..."
tst.Open sql ...
tst.MoveFirst
do while Not rs.eof
Response.Write Server.HTMLEncode(rst("LastName"))
rst.MoveNext
Loop
32ASP Query: Build SQL
Codestin Search App
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.open "PetStore",”
sql = "SELECT AnimallD, Name, Category, Breed, DateBorn, Color, ListPrice "
sql = sql & "FROM Animal WHERE (Category ="
sql = sql & Request.Form("Category") & ") AND (Color LIKE “*"
sql = sql & Request.Form("Color”) &"™)"
Set rst = Server.CreateObject("ADODB. Recordset")
rst-Open sql, objConn, 3, 3
33ASP Query: Create Table
ASPSearch1
AnimallD | Name | Category |
Breed | DateBorn |
Color | ListPrice |
<%
On Error Resume Next
tst.MoveFirst
do while Not rst.eof
%>
<%=Server.HTMLEncode(rst("AnimallD"))%>
|
erver. HTMLEncode(rst("Name"))%>
‘erver.HTMLEncode(rst("Category"))%>
erver. HTMLEncode(rst("Breed"))%>
<%=Server. HTMLEncode(rst("DateBorn"))%>
|
server. HTMLEncode(rst("Color"))%>
<%=Server. HTMLEncode(rst("ListPrice"))%>
|
<%
rst MoveNext
aClient-Server Data Transfer
Order Form
Order ID 4015
Customer | Jones, Martha y
Order Date 12-Aug
What if there are 10,000 customers?
How much time to load the combo box?
How do you refresh/reload the combo box?
Alternatives?XML: Transferring Data
Order: OrderlD, OrderDate DTD: Document Type
Definition is hierarchical.
Item: ItemID, Quantity, Cost
+ Repeats 1 or more
Item: ItemID, Quantity, Cost g Eee Carries
Item: ItemID, Quantity, Cost #PCDATA: parsed
_character data
Ce
36XML Data Example
‘
1
3/6/2001
$33.54
Need immediately.
30
Flea Collar-Dog-
Medium
208
$4.42
27
Aquarium Filler &
Pump
8
$24.65
XML: extensible markup
languageXML Example in Explorer
~
-
1
3/6/2001
$33.54
Need immediately.
—
30
Flea Collar-Dog-Medium
208
$4.42
27
Aquarium Filter & Pump
8
$24.65
+
+