辽宁石油化工大学计算机与通信工程学院(1).ppt
1,数据库管理系统DatabaseManagementSystems,Chapter10DistributedDatabases第十章分布式数据库,2,DistributedDatabases,DefinitionAdvantages/UsesProblems/ComplicationsClient-Server/SQLServerMicrosoftAccess,Britain,Germany,France,Italy,,,,SELECTSalesFROMBritain.SalesUNIONSELECTSalesFROMFrance.SalesUNIONSELECTSalesFROMItaly.Sales,3,DistributedDatabaseDefinition,MultipleindependentdatabasesEachDBMSisacompleteDBMSengine,queries,locking,transactions,etc.Usuallyondifferentmachines.Usuallyindifferentlocations.Connectedbyanetwork.MightbedifferentenvironmentsHardwareOperatingSystemDBMSSoftware,,,,,,,,DatabaseZeus,DatabaseApollo,DatabaseAthena,UnitedStates,England,France,4,DistributedDatabaseRules,C.J.DateRule0Transparencytheusershouldnotknoworcarethatthedatabaseisdistributed.Localautonomy.Norelianceonacentralsite.Continuousoperation.Locationindependence.Fragmentationindependencephysicalstorage.Replicationindependence.,Distributedqueryprocessing.Distributedtransactionmanagement.Hardwareindependence.Operatingsystemindependence.Networkindependence.DBMSindependence.,5,DistributedFeatures,Eachdatabasecancontinuetorunevenifportionfails.Dataandhardwarecanbemovedwithoutaffectingoperationsorusers.Expandingoperations.Peranceissues.Systemexpansionandupgrades.Addnewsectionwithoutaffectingothers.Upgradehardware,networkandDBMS.,6,AdvantagesandApplications,BusinessoperationsareoftendistributedWorkanddataaresegmentedbydepartment.Workanddataaresegmentedbygeographicallocation.ImprovedperanceMostupdatesandqueriesareperedlocally.Maintainlocalcontrolandresponsibilityoverdata.Canstillcombinedataacrossthesystem.ScalabilityandexpansionAddon,notreplacement.,,,,,,,,,,,,,localtransactions,,futureexpansion,7,CreatingaDistributedDatabase,Designadministrationplan.ChoosehardwareandDBMSvendor,andnetwork.SetupnetworkandDBMSconnections.Chooselocationsfordata.Choosereplicationstrategy.Createbackupplanandstrategy.Createlocalviewsandsynonyms.Perstresstestloadsandfailures.,8,DistributedQueryProcessing,NetworksareslowDrives20-60MBpersec.LANs1-10MBpersec10-100mbps.WANs0.01-5MBpersec.FasterispossiblebutexpensiveSANs10-100MBpersec.Goalistominimizetransmissions.Eachsystemmustbecapableofuatingqueries--preferablySQL.Resultsdependheavilyonhowthesystemjoinstables.,,,,10-20MB,10-100MB,0.1-5MB,Diskdrive,LAN,WAN,9,CustomersC,1,000,000,NY,ProductsP,Color10,000,000,SalesS,C,Sdate20,000,000SaleItemS,P,50,000,000,Chicago,LA,DistributedQueryProcessing,ExampleNYCustomers1MrowsLAProduction10MrowsChicagoSales20MrowsQueryListcustomerswhoboughtblueproductsonMarch1Badidea1TransferallrowstoChicagoThenJOINandselect.Betteridea2probablyTransferblueproductsfromLAtoChicagoBetteridea3GetsaleitemsonMarch1GetblueproductsfromLASendCtoNY,,,,,PsoldonMarch1,BluePsoldonMarch1,ClistfromdesiredP,MatchingCustomerdata,10,DataReplication,GoalsMinimizetransmissionsImproveperanceSupportheavymultiuseraccess.ProblemsUpdatingcopiesBulktransmissionsSiteunavailableConcurrencyEasierfortwopeopletochangethesamedataatthesametime.Decisionsupportsystems.Datawarehouse.,BritainCustomers,AlldatafromalltablesarereadbyPC,whichpersJOINandWHEREtest.Ifavailable,readsindexfirst.,,,18,LANFileServerSlow,FileServer,CustIDName115Jenkins125Juarez...,Order...,MyFile.mdb,s,SELECT*FROMCustomerWHERECity“Sandy”,,DBMSsoftwaretransferred.,,Applicationandquerytransferred.,,,,Onerowatatimetransferred,untilallrowsareexamined.,19,Client-ServerDatabases,Onemachinemachineisdominantserverandhandlesdataanyclients.Clientmachineshandlefront-endtasksandsmalldatatablesthatarenotshared.,FileServer,DBMSSQLServer,SharedData,application,,SELECT...,,SendSQLstatement.,,Returnmatchingdata.,20,ADOandDirectConnections,DatabaseServer,VisualBasicapplication,DBMStransport,ADO,ClientComputer,DBMStransport,ServerComputer,,,,SELECT,Results,TheDatabasevendorprovidesitsowndatatransporte.g,.OracleorSQLServerinstalledontheserverandtheclient.ADOprovidesadriverthatconnectsyourapplicationtothetransportservices.ODBCcanserveasthedatatransportifnothingelseisavailable,,,,,21,,Three-TierClient-Server,ServerDatabasesClientfront-endMiddleLocatedatabasesBusinessrulesProgramcode,Client,Middleware,DatabaseServers,,,,Application.Front-end.UserInterface.,Databases.Transactions.Legacyapplications.,Databaselinks.Businessrules.Programcode.,22,,DatabaseIndependenceontheClient,,,,,,NewDBMS,,,,,,OriginalDBMS,Application,ADO,ADO,,,,,23,DatabaseIndependencewithQueries,SELECTSaleID,SaleDate,CustomerID,CustomerNameFROMSaleCustomer,SELECTSaleID,SaleDate,CustomerID,LastName||‘,‘||FirstNameASCustomerNameFROMSale,CustomerWHERESale.CustomerIDCustomer.CustomerID,SELECTSaleID,SaleDate,CustomerID,LastName‘,‘FirstNameASCustomerNameFROMSaleINNERJOINCustomerONSale.CustomerIDCustomer.CustomerID,IndependentApplicationQueryworkswithanyDBMS,SavedOracleQuery,SavedSQLServerQuery,24,TheInternetasClient-Server,ClientBrowser,Server,WebServer,Router,Router,,,,Internet,,,,,,,,,,,HTMLpagessGraphics,http//server.location/page,,request,,ination,,25,HTMLLimitedClients,MymainpageMytextgoesinparagraphs.AdditionaltagssetboldfaceandItalic.Tablesaremorecomplicatedanduseasetoftagsforrowsandcolumns.FirstcellSecondcellNextrowSecondcolumnTherearetagstocreatesforcollectingdata.ButyouneedCGIprogramcodetoconvertandusethedata.,26,HTMLOutput,27,WebServerDatabaseFundamentals,Client/Browser,WebServer,HTML,,,1,,,Data,DBMS,2,.html,Query,Database,Result,,,,,,QueryTemplateCode,Programcode,,,PageTemplateResult,,ResultPage,1,2,3,1,2,3,,CGIString,,0,RequestServer/.html,HTML,,,,,,,,,28,DatabaseExampleClientSide,0,RequestServer/.html,1,2,Server,,,,,3,Results,CallASPpage,Initial,29,Client-ServerDataTransfer,Order,OrderDate,Customer,12-Aug,Jones,Martha,,,OrderID,1015,Whatifthereare10,000customersHowmuchtimetoloadthecomboboxHowdoyourefresh/reloadthecomboboxAlternatives,30,Latency,,time,Server,Client,,Generate,received,Userdelay,,,Receivedata,Transmissiondelay,Transmissiondelay,31,XMLTransferringData,OrderOrderID,OrderDate,ShippingCost,Comment,ItemItemID,Description,Quantity,Cost,ManyXMLfilescontainhierarchicaldata.,ItemItemID,Description,Quantity,Cost,ItemItemID,Description,Quantity,Cost,32,XMLSchemaDefinitionxsd,,Partialfile,generatedby.NETxsd.,33,XMLDataExample,XMLextensiblemarkuplanguage,34,XMLExampleinExplorer,35,JavaandJDBC,ConnectionconDriverManager.getConnection“jdbc.myDrivermyDBName“,“myLogin”,“myPassword”;Statementsmtcon.CreateStatement;ResultSetrstsmt.cuteQuery“SELECTAnimalID,Name,Category,BreedFROMAnimal”;whilerst.next{intiAnimalrst.getInt“AnimalID”;StringsNamerst.getString“Name”;StringsCategoryrst.getString“Category”;StringsBreedrst.getString“Breed”;\\Nowdosomethingwiththesefourvariables},