Professional Documents
Culture Documents
D A T A B A S E
Distributed 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 Italy.Sales
Germany
Britain
France
Italy
2
D A T A B A S E
England France
Database Athena
United States
D A T A B A S E
D A T A B A S E
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.
D A T A B A S E
local transactions
Improved performance
Most updates and queries are performed locally. Maintain local control and responsibility over data.
future expansion
Can still combine data across the system. Scalability and expansion
Add on, not replacement.
6
D A T A B A S E
D A T A B A S E
WAN 0.1 - 5 MB
10 - 20 MB Disk drive
10-100 MB LAN
D A T A B A S E
Example
NY: Customers: 1 M rows Customers(C#, ) LA: Production: 10 M rows 1,000,000 C# list from Chicago: Sales: 20 M rows desired P# Query: List customers who Chicago Matching bought blue products on March 1 Sales(S#, C#, Sdate) Customer Bad idea #1 data 20,000,000 SaleItem(S#, P#,) Transfer all rows to Chicago 50,000,000 Then JOIN and select. Better idea #2 (probably) P# sold on Transfer blue products from LA March 1 to Chicago Blue P# sold on Better idea #3 LA March 1 Get sale items on March 1 Products(P#, Color) Get blue products from LA 10,000,000 Send C# to NY
9
D A T A B A S E
Data Replication
Goals
Minimize transmissions Improve performance Support heavy multiuser access. Britain
Britain: Customers & Sales France: Customers & Sales Spain: Customers & Sales Periodic updates Market research & data corrections.
Problems
Updating copies
Bulk transmissions Site unavailable
Concurrency
Easier for two people to change the same data at the same time.
Spain
Britain: Customers & Sales France: Customers & Sales Spain: Customers & Sales Update data.
10
D A T A B A S E
Jones
8898
DBMS #2 Accounts
Jones 3561
11
D A T A B A S E
1. Prepare to commit. All agree? Coordinator sends message 2. Commit and data to all machines to get ready. Local machines save data in logs, verify update status and return message. If all locals report OK, then Database 2 Lock tables. coordinator writes log and Database 3 Save log. instructs others to proceed. Update all tables. If any fail, it sends Rollback message.
12
D A T A B A S E
Resource Manager
DBMS Transaction Manager
Transaction Processing DBMS Monitor The distributed transaction coordinator/transaction processing monitor handles the transaction decisions and coordinates across the participating systems.
13
Resource Manager
D A T A B A S E
14
D A T A B A S E
View
user permissions
15
D A T A B A S E
Client-Server
Server Server
Shared Database
16
D A T A B A S E
Performance improvements.
Indexes are crucial. Store some data on each PC (replication). Store applications on PC (graphics & forms). Convert to SQL-Server
All data from all tables are read by PC, which performs JOIN and WHERE test. If available, reads index first.
SELECT Name, SaleDate FROM Customer INNER JOIN Sales ON Customer.C# = Sales.C# WHERE SaleDate BETWEEN #1-Mar-97# AND #9-Mar-97#;
17
D A T A B A S E
18
D A T A B A S E
Client-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.
19
D A T A B A S E
The Database vendor provides its own data transport (e.g,. Oracle or SQL Server) installed on the server and the client. ADO provides a driver that connects your application to the transport services. ODBC can serve as the data transport if nothing else is available
D A T A B A S E
Three-Tier Client-Server
Databases. Server Databases Transactions. Client front-end Legacy applications. Middle
Locate databases Business rules Program code
Database Servers
Middleware
Client
21
D A T A B A S E
ADO
ADO
Application
22
D A T A B A S E
SELECT SaleID, SaleDate, CustomerID, LastName + , + FirstName AS CustomerName FROM Sale INNER JOIN Customer ON Sale.CustomerID = Customer.CustomerID
23
D A T A B A S E
http://server.location/page
24
D A T A B A S E
<HTML> <HEAD> <TITLE>My main page</TITLE></HEAD> <BODY BACKGROUND=graphics/back0.jpg> <P>My text goes in paragraphs.</P> <P>Additional tags set <B>boldface</B> and <I>Italic</I>. <P>Tables are more complicated and use a set of tags for rows and columns.</P> <TABLE BORDER=1> <TR><TD>First cell</TD><TD>Second cell</TD></TR> <TR><TD>Next row</TD><TD>Second column</TD></TR> </TABLE> <P>There are form tags to create input forms for collecting data. But you need CGI program code to convert and use the input data.</P> </BODY> </HTML>
25
D A T A B A S E
HTML Output
My t ext goes in pa ragra phs. Addit iona l t a gs set bold fac e a nd Italic. Ta bles a re m ore com plica t ed a nd use a set of ta gs for rows a nd colum ns. F irst cell Second cell Next row Second colum n There a re form ta gs t o crea t e input form s for collect ing da t a . But you need CGI progra m code t o convert a nd use t he input da ta .
26
D A T A B A S E
Client/Browser
Database 1 2 Data 3 HTML Form 2 DBMS 1 Result Query Web Server Result Page 1 HTML form Form.html 2 Query Template + Code Program code
27
D A T A B A S E
Server
28
D A T A B A S E
What if there are 10,000 customers? How much time to load the combo box?
D A T A B A S E
Latency
Server
Generate form
Transmission delay
Transmission delay
time
Form received
Client User delay
30
D A T A B A S E
Order: OrderID, OrderDate, ShippingCost, Comment Item: ItemID, Description, Quantity, Cost Item: ItemID, Description, Quantity, Cost Item: ItemID, Description, Quantity, Cost
31
D A T A B A S E
<?xml version="1.0" encoding="utf-8"?> <xs:schema id="OrderList" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="OrderList" msdata:IsDataSet="true"> <xs:complexType> Partial file, <xs:choice maxOccurs="unbounded"> generated by <xs:element name="Order"> <xs:complexType> .NET xsd.exe <xs:sequence> <xs:element name="OrderID" type="xs:string" minOccurs="0" /> <xs:element name="OrderDate" type="xs:date" minOccurs="0" /> <xs:element name="ShippingCost" type="xs:string" minOccurs="0" /> <xs:element name="Comment" type="xs:string" minOccurs="0" /> <xs:element name="Items" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="ItemID" nillable="true" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent msdata:ColumnName="ItemID_Text" msdata:Ordinal="0"> <xs:extension base="xs:string"> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="Description" nillable="true" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent msdata:ColumnName="Description_Text" msdata:Ordinal="0"> <xs:extension base="xs:string"> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element>
32
D A T A B A S E
33
D A T A B A S E
34
D A T A B A S E
35