0% found this document useful (0 votes)
9 views

Section Database System

Uploaded by

akash aku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
9 views

Section Database System

Uploaded by

akash aku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 36
anagement Systems Chapter 11 Distributed Databases Jerry Post Copyright © 2001 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 lItaly.Sales Germany France Distributed 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 States Distributed 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 = 6 Creating 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 drive Distributed 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,000 Data 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 ‘Locked Transactions & 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 Yes Distributed Databases In Oracle ~ Database Links Schema.Table@Location + Full database names. Scott.Emp@hq.acme.com + 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. permissions Client-Server Server Clients Clients Shared Database Front-end User Interface LAN 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#; 16 LAN 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 WHERE 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. Send SQL statement. | application Microsoft 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 Queries Open 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 Computer ODBC 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. 21 ADO 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 22 Three-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 25 The Internet as Client-Server information Internet Router lent) (oes Browser Web Server http://server.location/page Pintpaces Forms Graphics HTML Limited Clients My main page
a

Category

Color

at ASP 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 32 ASP Query: Build SQL Animal Search Results <% 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 33 ASP Query: Create Table <% On Error Resume Next tst.MoveFirst do while Not rst.eof %> erver. HTMLEncode(rst("Name"))%>
‘erver.HTMLEncode(rst("Category"))%>
erver. HTMLEncode(rst("Breed"))%>
server. HTMLEncode(rst("Color"))%>
<% rst MoveNext
ASPSearch1
AnimallD Name Category Breed DateBorn Color ListPrice
<%=Server.HTMLEncode(rst("AnimallD"))%>
<%=Server. HTMLEncode(rst("DateBorn"))%>
<%=Server. HTMLEncode(rst("ListPrice"))%>
a Client-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 36 XML 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 language XML 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 + +

You might also like