Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATABASE 1 Distributed Databases  Definition  Advantages / Uses  Problems / Complications  Client-Server / SQL Server  Microsoft Access Britain Germany.

Similar presentations


Presentation on theme: "DATABASE 1 Distributed Databases  Definition  Advantages / Uses  Problems / Complications  Client-Server / SQL Server  Microsoft Access Britain Germany."— Presentation transcript:

1 DATABASE 1 Distributed Databases  Definition  Advantages / Uses  Problems / Complications  Client-Server / SQL Server  Microsoft Access Britain Germany France Italy SELECT Sales FROM Britain.Sales UNION SELECT Sales FROM France.Sales UNION SELECT Sales FROM Italy.Sales

2 DATABASE 2 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 Database Apollo Database Athena United States England France

3 DATABASE 3 Distributed Database Rules  C.J. Date  Rule 0: Transparency: the user should not know or care that the database is distributed.  Local autonomy.  No reliance on a central site.  Continuous operation.  Location independence.  Fragmentation independence (physical storage).  Replication independence.  Distributed query processing.  Distributed transaction management.  Hardware independence.  Operating system independence.  Network independence.  DBMS independence.

4 DATABASE 4 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.

5 DATABASE 5 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.  Scalability and expansion  Add on, not replacement. local transactions future expansion

6 DATABASE 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.

7 DATABASE 7 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. 10 - 20 MB 1 - 10 MB 0.1 - 5 MB Disk drive LAN WAN

8 DATABASE 8 Customers(C#, …) 1,000,000 NY Products(P#, Color…) 10,000,000 Sales(S#, C#, Sdate) 20,000,000 SaleItem(S#, P#,…) 50,000,000 Chicago LA Distributed Query Processing  Example  NY: Customers: 1 M rows  LA: Production: 10 M rows  Chicago: Sales: 20 M rows  Query: List customers who bought blue products on 1-Mar-01  Bad idea #1 Transfer all rows to Chicago Then JOIN and select.  Better idea #2 (probably) Transfer blue products from LA to Chicago  Better idea #3 Get sale items on 1-Mar-01 Get blue products from LA Send C# to NY P# sold on 1-Mar-01 Blue P# sold on 1-Mar-01 C# list from desired P# Matching Customer data

9 DATABASE 9 Data Replication  Goals  Minimize transmissions  Improve performance  Support heavy multiuser access.  Problems  Updating copies Bulk transmissions Site unavailable  Concurrency Easier for two people to change the same data at the same time.  Decision support systems.  Data warehouse. Britain: Customers & Sales France: Customers & Sales Spain: Customers & Sales Britain Britain: Customers & Sales France: Customers & Sales Spain: Customers & Sales Spain Update data. Market research & data corrections. Periodic updates

10 DATABASE 10 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.  Optimistic updates.  Two-phase commit. DBMS #1 Accounts Jones8898 DBMS #2 Accounts Jones3561 Transaction A Locked Waiting Transaction B Waiting Locked

11 DATABASE 11 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.  If all locals report OK, then coordinator writes log and instructs others to proceed. If any fail, it sends Rollback message. Database 1 Initiate Transaction Database 2 Database 3 1. Prepare to commit. All agree? 2. Commit Lock tables. Save log. Update all tables.

12 DATABASE 12 Distributed Design Questions

13 DATABASE 13 Distributed Databases In Oracle  Database Links  Full database names.  CONNECT command.  Linking through synonyms.  CREATE SYNONYM …  Central control over permissions.  Linking through Views/queries.  CREATE VIEW AS …  Can assign local permissions.  Linking through stored procedures.  DELETE …  Strong control over actions. Schema.Table@Location Scott.Emp@hq.acme.com Server database View Synonym: Employee Procedure: DELETE FROM Employee WHERE... user permissions User can only run procedure. No other access.

14 DATABASE 14 Client-Server Server Clients Shared Database Front-end User Interface

15 DATABASE 15 LAN 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.  Retrieves all needed data across the network.  Performance improvements.  Indexes are crucial.  Store some data on each PC (replication).  Store applications on PC (graphics & forms).  Convert to SQL-Server File Server DBMS data file Application Shared Data SELECT Name, SaleDate FROM Customer INNER JOIN Sales ON Customer.C# = Sales.C# WHERE SaleDate BETWEEN #1-Mar-97# AND #9-Mar-97#; All data from all tables are read by PC, which performs JOIN and WHERE test. If available, reads index first.

16 DATABASE 16 LAN File Server: Slow File Server CustIDName… 115Jenkins… 125Juarez... Order... MyFile.mdb Forms SELECT * FROM Customer WHERE City = “Sandy” DBMS software transferred. Application and query transferred. One row at a time transferred, until all rows are examined.

17 DATABASE 17 Client-Server Databases  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. File Server DBMS SQL Server Shared Data application SELECT... Send SQL statement. Return matching data.

18 DATABASE 18 Microsoft Access  Access is a client-side database.  In file server environment.  As a client 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

19 DATABASE 19 Open Database Connectivity: ODBC  Microsoft connectivity standard.  Most DBMS companies provide drivers.  SQL Server, Oracle, Ingres, etc.  Driver is installed on PC and Server.  ODBC handles:  Login to database.  Send query.  Interpret result codes.  Exchange data. Database Server Access ODBC driver Link Tables Client Computer ODBC driver Server Computer SELECT … Results

20 DATABASE 20 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 DATABASE 21 ADO and Direct Connections Database Server Visual Basic application DBMS transport ADO Client Computer DBMS transport Server Computer SELECT … Results 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

22 DATABASE 22 Access Pass-Through Queries  Send a query to another machine for processing.  Access does not parse or alter the query.  Can use SQL specific to other machine.  Only transmission is SQL text and results returned.  Two types of queries  Action: no returned data.  Select: multiple rows returned as snapshot.  Create pass-through query.  Query Design, SQL specific, Pass- Through.  Programming. DB machine SQL Server Personal Computer ODBC driver SELECT... Data/ Results Login to database. Send query. Interpret result code. Pass data to Access. Access Store/transfer query. Store results/snapshot.

23 DATABASE 23 Replication Complications (Access)  Windows 95 introduced replication.  Windows Briefcase.  Access Developers Toolkit (ADT) Replication Manager.  Program code.  Synchronization  Manually, e.g., laptop. From menu. Drag and drop on briefcase.  From code, e.g., full-time network connection.  Changes the database.  Cannot use passwords (7.0)  Columns added to all tables. GlobalID Change history.  Tables added to database. Replication errors.  AutoNumber becomes random. Replication makes it difficult to assign unique IDs. Might use GlobalID. Do not rely on sequencing.

24 DATABASE 24 Three-Tier Client-Server  Server Databases  Client front-end  Middle  Locate databases  Business rules  Program code Client Middleware Database Servers Application. Front-end. User Interface. Databases. Transactions. Legacy applications. Database links. Business rules. Program code.

25 DATABASE 25 The Internet as Client-Server Client Browser Server Web Server Router Internet HTML pages Forms Graphics http://server.location/page request information

26 DATABASE 26 HTML Limited Clients My main page My text goes in paragraphs. Additional tags set boldface and Italic. Tables are more complicated and use a set of tags for rows and columns. First cell Second cell Next row Second column There are form tags to create input forms for collecting data. But you need CGI program code to convert and use the input data.

27 DATABASE 27 HTML Output

28 DATABASE 28 Web Server Database Fundamentals Client/Browser HTML Form Action= “Query.asp” Web Server (IIS) HTML form 1 Data SQL Server 2 Form.html Query Database Result Query Template + Code Query.asp Page = Template + Result Result Page 123 1 2 3 Form CGI String 0 Request Server/Form.html

29 DATABASE 29 Database Example: Client Side 0 Request Server/Form.html 1 2 Server 3 Results Call ASP page Initial form

30 DATABASE 30 Form Code Catalog Search Cat Dog Fish Category Color 1

31 DATABASE 31 ASP Code Structure Note:Access will create the basic structure. Export a query as asp. Then edit the file. Connect to the Database Create the SQL Connect to the Database/Recordset Loop through the Recordset Get a Field Display it Move to the next row End Loop Set objConn = CreateObject("ADODB.Connection") Set rst = CreateObject("ADODB.Recordset") sql = " SELECT …" rst.Open sql … rst.MoveFirst do while Not rs.eof Response.Write Server.HTMLEncode(rst(”LastName")) rst.MoveNext Loop 2

32 DATABASE 32 ASP Query: Build SQL Animal Search Results <% Set objConn = Server.CreateObject("ADODB.Connection") objConn.open "PetStore","","" sql = "SELECT AnimalID, 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 DATABASE 33 ASP Query: Create Table ASPSearch1 AnimalID Name Category Breed DateBorn Color ListPrice <% On Error Resume Next rst.MoveFirst do while Not rst.eof %> <% rst.MoveNext loop %>

34 DATABASE 34 Client-Server Data Transfer Order Form Order Date Customer 12-Aug Jones, Martha Order ID 1015 What if there are 10,000 customers? How much time to load the combo box? How do you refresh/reload the combo box? Alternatives?

35 DATABASE 35 XML: Transferring Data Order: OrderID, OrderDate Item: ItemID, Quantity, Cost DTD: Document Type Definition is hierarchical. +Repeats 1 or more ?Optional *Repeats 0 or more #PCDATA: parsed character data

36 DATABASE 36 XML Data Example 1 3/6/2001 $33.54 Need immediately. 30 Flea Collar-Dog- Medium 208 $4.42 27 Aquarium Filter & Pump 8 $24.65 XML: extensible markup language

37 DATABASE 37 XML Example in Explorer


Download ppt "DATABASE 1 Distributed Databases  Definition  Advantages / Uses  Problems / Complications  Client-Server / SQL Server  Microsoft Access Britain Germany."

Similar presentations


Ads by Google