数据库-研究生课件:第二部分 数据库系统实现技术_第1页
数据库-研究生课件:第二部分 数据库系统实现技术_第2页
数据库-研究生课件:第二部分 数据库系统实现技术_第3页
数据库-研究生课件:第二部分 数据库系统实现技术_第4页
数据库-研究生课件:第二部分 数据库系统实现技术_第5页
已阅读5页,还剩58页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第二部分数据库系统实现技术主要内容第3章存储与文件结构(简介+自学)第4章索引与散列(简介+自学)第5章查询处理第6章查询优化第7章事务第8章并发控制第9章恢复系统开源代码数据库管理系统Derby/Cloudscape分析主要任务有选择的深入了解并掌握部分DBMS核心模块的实现细节通过对开源代码数据库管理系统Derby的分析,学习实现DBMS核心的相关技术原理开源代码分析方法和技巧基础收集整理相关资料对相关基本原理的深刻理解和掌握原则先总体(宏观)后局部(微观)先抽象(接口)后细节(实现)步骤从系统架构分析入手,逐步深入应用软件分析工具动手实验和阅读代码很重要ArchitectureofaDBMSDiskSpaceManagerDBMSIndexFilesDataFilesSystemCatalogDatabaseArchitectureofaDBMSDiskSpaceManagerDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)ArchitectureofaDBMSFiles&AccessMethodsBufferManagerDiskSpaceManagerDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)ArchitectureofaDBMSFiles&AccessMethodsBufferManagerDiskSpaceManagerOperatorEvaluatorPlanExecutorParserOptimizerQueryExecutionEngineDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)ArchitectureofaDBMSTransactionManagerLockManagerConcurrencyControlFiles&AccessMethodsBufferManagerDiskSpaceManagerOperatorEvaluatorPlanExecutorParserOptimizerQueryExecutionEngineDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)ArchitectureofaDBMSTransactionManagerLockManagerConcurrencyControlRecoveryManager(Logging&Recovery)Files&AccessMethodsBufferManagerDiskSpaceManagerOperatorEvaluatorPlanExecutorParserOptimizerQueryExecutionEngineDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)ArchitectureofaDBMSTransactionManagerLockManagerConcurrencyControlRecoveryManager(Logging&Recovery)Files&AccessMethodsBufferManagerDiskSpaceManagerOperatorEvaluatorPlanExecutorParserOptimizerQueryExecutionEngineDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)AccessControlManagerArchitectureofaDBMSTransactionManagerLockManagerConcurrencyControlRecoveryManager(Logging&Recovery)Files&AccessMethodsBufferManagerDiskSpaceManagerOperatorEvaluatorPlanExecutorParserOptimizerQueryExecutionEngineDBMSIndexFilesDataFilesSystemCatalogDatabaseApplications(WebForms,SQLInterface)IntegrityManagerAccessControlManagerArchitectureofaDBMS(9/30)ArchitectureofaDBMSArchitectureofaDBMSInterfaceSQLCommandsDBMSArchitectureIntroducingApacheDerbyAnOpenSourscePureJavaRelationalDatabaseEngineWhat

isDerby?OpenSourceDatabaseTechnologyPureJavaEasytouseSmallfootprintStandardsbasedCompleterelationaldatabaseengineSecureSub-projectofApacheDBProject/derbyDerbyHistory1996:Cloudscapefounded–Oakland,CA1997:JDBMS1.0ReleasedApr1999:Cloudscape2.0Dec1999:AcquiredbyInformixSoftwareJune2001:Cloudscape4.0ReleasedJuly2001:AcquiredbyIBMDec2001:IBMCloudscape5.0Released2003:IBMCloudscape5.1,5.1FP1&FP2August2004:IBMdonatedCloudscapetoApacheJuly2005:DerbygraduatedfromApacheIncubatorDerby@ApacheSoftwareFoundationIBMcontributedtheCloudscapecodetoApacheSoftwareFoundationasDerbyReleasedundertheApachev2.0LicenseCommunityisgrowing,openinvitationtocontributetowardsthesuccessoftheprojectandcommunityParticipateasauser,contributor,orboth.ContributewithSourcecodeDocumentation(papers,presentationsetc.)Suggestions,ideas,bugreportsorjusthelpothersoutonthemaillistsMay16200521ApacheDerbyvs.CloudscapeDerby:DatabaseEngine+EmbeddedJDBCDriver+NetworkServer+Tools(ij,dblook,import/export)+Usermanuals(web-accessible)Clouldscape:Derby+TechnicalSupport+DB2UniversalJDBCDriver(JCC)+ODBC+DB2Plug-inforEclipse(databasebrowsingTool+Manuals(eclipse-basedandPDF)FeaturesofDerbyPureJavaEmbeddeddatabaseSmallfootprintStandardsbasedCompleterelationaldatabaseengineEasytouseanddeployPureJavaDatabasecodewritteninJavaWriteOnceRunAnywhereRequiresaJ2SE1.3,1.4or1.5virtualmachineAnyhardware,anyoperatingsystem,anyvendorSinglebinarydoesruneverywhereLinux,Windows,MacOs,AIX,Solaris,Z/OS,AS400,OS/390,…Databaseon-diskformatisplatformindependentSmallFootprintEnginejarfileisaround2MbOptionalJarfilesNetworkserver~150kTools~200kRuntimememoryuseDependentonapplication,datacachingetc.CanrunwhenJavaheapmemoryrestrictedto4MbHaveruninmachineswithonly16MbphysicalmemoryEmbeddedDatabaseDatabaseenginebecomesintegralpartoftheJavaapplicationNoadditionalprocess➢Application'sJDBCcallsnowjustresultinmethodcallswithinsameJVMJustaJarfiletotheapplicationDatabaseinvisibletoenduserofapplicationEmbedded

DerbywithApplicationDatabaseonlyaccessiblefromsingleJVMJava/JDBConlyNonetworkconnectivityTypicallyissingleapplicationperJVM(butcouldbemultiple)Embedded

DerbywithApplicationEasytouseFastZeroadministrationEmbeddedinApplication

ServerDerbyEmbeddedPros:Invisibleatthedeployedsite–simplystartyourapplicationVerysimpletodeployandmanageStillhavemulti-threaded,multi-connectioncapabilityPerformanceisverygoodCons:Nonetworkingcapability(butnosecurityissues)Only1JVMcanaccessadatabaseatanygiventimeTraditionalClient/ServerJavaVirtualMachineDerbyengineNetwork

ServerDRDAJDBCCLI/ODBCMultipleClientapplications

-RemoteorlocalPHPontopofODBCClientApplications

ClientsprovidedbyIBMDMDatabase(s)ondiskDerby’sClient/ServerModeAccessfromasingleVMinembeddedmodecanbearestrictionNetworkServerallowsDerbytoactasatraditionalclientserverdatabaseIndustrystandardDRDAoverTCP/IPNetworkServeritselfispureJavaUsesembeddedJDBCdriveragainstDerbyIt’saJavaDRDAtoJDBCconverterNetworkServerClientsJDBCusingIBM’sDB2UniversalJDBCClientDifferentdriverandJDBCURLtoembeddedDataSourceandConnectionPoolingDataSourceODBC/CLIusingIBM’sDB2’sUniversalODBC/CLIclientEnablesPHP/Perl/.NETUniversaldriversenabledbyuseofDRDAJavaVirtualMachineDerbyengineNetwork

ServerDRDAJDBCCLI/ODBCEspeciallyusefuldeveloping

&debuggingembeddeddatabaseusage

PHPontopofODBCClientApplications

ClientsprovidedbyIBMDMDatabase(s)ondiskEmbeddedNetworkServerApplicationEmbeddedNetworkServerAddsontoembeddedenginetoprovideaccesstodatabasefromoutsidetheapplication’sVM(fromlocalorremotemachine)AllowsdeveloperstoworkondatabasewhilestandaloneapplicationisrunningAllowsreportingcapabilitytobeaddedontoastandaloneapplicationEnabledbypropertysettingandadditionaljarfile,nocodechangestoapplicationderby.drda.startNetworkServer=trueODBC/DerbyenvironmentInstallDB2Run-TimeClientStartDerbyNetworkServer(Derbymustbeinstalled!)ConfigureDerbyDBasODBCDataSourceCatalognodeanddatabaseviaDB2CommandLineProcessor,CLPCatalogdatabaseasODBCdatasourcedb2=>catalogtcpipnodeDNSremotelocalhostserver1527--DerbyNetworkServerdb2=>catalogdbDDBatnodeDNSauthenticationserverdb2=>catalogsystemodbcdatasourceDDBWriteanODBCApplicationtoaccesstheDerbydatabase,DDBCompleteRelationalEngineSQLTables,indexes,views,triggers,procedures,functions,temptablesforeignkeysandconstraintsjoins,costbasedoptimizerMulti-user,transactions,isolationlevels,deadlockdetection,crashrecovery,backup&restoreDatacaching,statementcaching,writeaheadlogging,groupcommitMultipledatabasespersystemStandardstoAllowMigrationDerbydoesperformwellinitsownrightLackingfeaturesofanenterpriseDBDeveloponDerby,deployonenterpriseDBInitialdeployonDerby,migratetoenterpriseDBasneededStandardsBasedSQLSQL92,SQL99,SQL2003,SQL/XML,…JavaJ2SE1.3,1.4,1.5J2ME/OSGiJDBC2.0&3.0JSR169J2EE–JDBCpassedCTSforJ2EE1.4&1.3DRDAV3OpenGroup(/)DerbyToolsij–SQLscriptingtoolJDBCneutral,canbeusedagainstotherJDBCdriversdblook–schemaextractiontoolforDerbysysinfo–DerbyversioninformationOutputusefulforbugrepoRTINginJiraDerbyIntegrationDerbyisreportedtoworkwithActiveMQ,Cocoon,C-JDBC,Daffodil,db2db,DB2Everyplace,DOTS,DroneIRCBot,Eclipse,Geronimo,Hibernate,iBATIS,IBMDB2JDBCUniversalDriver,IKVM.NET,iSQL-Viewer,SunJ2EESDK,JBoss,JOnAS,JPOXJDO,Jython,Maven,RedHatApplicationServer,RIFE,SQuirreLSQL,Sync4j,TomcatEasytoUseandDeployDerbyiseasytouseDesignedforJavadevelopers(standardJDBCcommands)Simplyloadthedriverandconnecttoadatabaseandyou’reinbusinessDerbyiseasytodeploySimplydeploythejarfile(s)andsettheusersclasspathEmbeddedrequiresnostartingandstoppingofaserverDesignedtobezeroadmin:noupdatestatistics,spacereclamation,logmanagement,etc.requiredEverythingcanbedoneprogrammaticallyincludingdatabasebackups,settingproperties,etc.DerbyArchitectureModuleArchitectureModuleSetofusablefunctionalityWelldefinedAPI–“protocol”ProtocolseparatedfromimplementationTypicallydeclaredassetofJavainterfacesIdentifiedbysingleJavainterface,“factoryclass”➢.apache.derby.iapi.services.locks.LockFactoryMayreferenceothermoduleprotocolsZeroormoreimplementationsinarunningsystemImplementationcanimplementcontrolinterfacesto:➢Defineadditionalboot&shutdownactions➢DefinesuitabilityforrequestedfunctionalityServiceCollectionofco-operatingmodulesprovidingacompletesetoffunctionalitySingleprimarymoduledefiningexternalAPIPersistent➢Boot-upstateinsinglepertiesfile,includingtherequiredprimarymoduleidentification(astheprotocol,nottheimplementation)Non-persistent➢Purelyrun-timedefinitionModulesalwaysbootedthroughmonitorMonitorManagesDerbysystemBoots&shutdownServicesFindspertiesfilebaseduponservicebootMapsrequestsforamoduleprotocoltoanimplementationBasedupon:➢Virtualmachineenvironment(J2ME/J2SE1.3/1.4)➢Availableclasses(e.g.JCEencryptionclasses)➢SuitabilityforcurrentserviceEnsuressystemisnotgarbagecollectedawayDatabaseEngineSystemSingleActiveThreadper

SessionCache/Lock

ManagersCacheManagercachesobjectsthatimplementaCacheableinterfaceHandlesaging,pruning,etc.Cachespages,statements,stringtranslations,openfiles,dictionaryobjectsLockManagerlocksobjectsthatimplementaLockableinterfaceLockcompatibilitydefinedbyLockable,notmanagerCentralizes“hard”thread-safeissuesSQLCompilationPreparedStatementps=conn.prepareStatement(“SELECT*FROMTWHEREID=?”);1)Lookupincacheusingexacttextmatch(skipto5ifplanfoundincache)2)ParseusingJavaCCgeneratedparser3)Bindtodictionary,gettypes,etc.4)Generatecodeforplan5)CreateinstanceofplanParsePhaseTreeofQueryNodescreatedManyNodes,oneperoperationtype➢FromBaseTable,MethodCallNode,DistinctNode,CurrenUserNode,...➢BulkofcodefootprintisSQLcompilerNoexecutioncodeinQueryNodes,leadstosimilarsetofexecutionResultSetsDuplicatecheckingofstateinQueryGeneratePhaseGenerateJavabytecodedirectly,intoin-memorybytearrayLoadwithspecialClassLoaderthatloadsfromthebytearraySingleClassLoaderpergeneratedclassAllowsstatementstobeagedoutindependentlyGeneratedclassextendsaninternalclassBaseActivationwhichprovidessupportmethods,commonfunctionalityActivation–InstanceofplanInstanceofgeneratedclasscalledActivationHoldsqueryspecificstate,parameters,etc.ConnectedindirectlytoJDBCPreparedStatementthroughholder/wrapperclassthatimplementsActivationinterfaceHolderallowscompiledplantochangewithoutknowledgeofapplication,transparenttoPreparedStatementActivation–ExecutionPreparedStatement.execute()methodsCreatestreeofinternalResultSetobjectsthatmaptoSQLoperations➢ScanResultSet➢SortResultSet➢IndexScanResultSetGeneratedcodemaingluecodeExpressionsaregeneratedasmethodsingeneratedclassStatementResultsBenefitsofGeneratedCodeNoneedtohaveDerbyspecificinterpreterwritteninJava,justuseJVMGeneratedcodewillgetJIT'edandthusgaintheperformancebenefitsTightintegrationwithJavacallsfromSQL,e.g.SQLfunctionswritteninJava.Nouseof(slow)reflection,justcompilemethodc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论