您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据结构与算法 > 数据库系统概念PPT第九章,对应原版教材第五版
©Silberschatz,KorthandSudarshan,BoZhou1.1DatabaseSystemConceptsChapter9:Object-BasedDatabasesComplexDataTypesandObjectOrientationStructuredDataTypesandInheritanceinSQLTableInheritanceArrayandMultisetTypesinSQLObjectIdentityandReferenceTypesinSQLImplementingO-RFeaturesPersistentProgrammingLanguagesComparisonofObject-OrientedandObject-RelationalDatabases©Silberschatz,KorthandSudarshan,BoZhou1.2DatabaseSystemConceptsOverviewTraditionaldatabaseapplications:Largeamountofrelativelysimpletypeofdata;Shortandsimpletransaction(task);Somenewapplicationsneeddatamanagementsupport.Withcomplexdatatype:computeraideddesign(CAD)andgeographicalinformationsystems(GIS)Object-RelationalDatabasesystem;Object-OrientedDatabaseSystem;Withlongandcomplextasks:verycomplexdataanalysis.DatawarehouseandDataMining©Silberschatz,KorthandSudarshan,BoZhou1.3DatabaseSystemConceptsObject-RelationalVsObjectOrientedObject-RelationalBasedontraditionalRelationalDatamodelExtendthedatamodeltosupportcomplexdatatype,includingobjectorientationandconstructstodealwithaddeddatatypes.Allowattributesoftuplestohavecomplextypes,includingnon-atomicvaluessuchasnestedrelations.Preserverelationalfoundations,inparticularthedeclarativeaccesstodata,whileextendingmodelingpower.DrivenbycommercialDBMSvendors.Object-OrientedBasedonobject-orientedprogramminglanguages,suchasC++,Java;Extendthedatapersistencyfeaturetotheprogramminglanguagetosupportdatastorageandmanipulation.©Silberschatz,KorthandSudarshan,BoZhou1.4DatabaseSystemConceptsComplexTypesandSQL:1999ExtensionstoSQLtosupportcomplextypesinclude:CollectionandlargeobjecttypesNestedrelationsareanexampleofcollectiontypesStructuredtypesNestedrecordstructureslikecompositeattributesInheritanceObjectorientationIncludingobjectidentifiersandreferencesOurdescriptionismainlybasedontheSQL:1999standardNotfullyimplementedinanydatabasesystemcurrentlyButsomefeaturesarepresentineachofthemajorcommercialdatabasesystemsReadthemanualofyourdatabasesystemtoseewhatitsupports©Silberschatz,KorthandSudarshan,BoZhou1.5DatabaseSystemConceptsStructuredTypesandInheritanceinSQLStructuredtypescanbedeclaredandusedinSQLcreatetypeNameas(firstnamevarchar(20),lastnamevarchar(20))finalcreatetypeAddressas(streetvarchar(20),cityvarchar(20),zipcodevarchar(20))notfinalNote:finalandnotfinalindicatewhethersubtypescanbecreatedStructuredtypescanbeusedtocreatetableswithcompositeattributescreatetablecustomer(nameName,addressAddress,dateOfBirthdate)Dotnotationusedtoreferencecomponents:name.firstname©Silberschatz,KorthandSudarshan,BoZhou1.6DatabaseSystemConceptsStructuredTypes(cont.)User-definedrowtypescreatetypeCustomerTypeas(nameName,addressAddress,dateOfBirthdate)notfinalCanthencreateatablewhoserowsareauser-definedtypecreatetablecustomerofCustomerType©Silberschatz,KorthandSudarshan,BoZhou1.7DatabaseSystemConceptsMethodsCanaddamethoddeclarationwithastructuredtype.methodageOnDate(onDatedate)returnsintervalyearMethodbodyisgivenseparately.createinstancemethodageOnDate(onDatedate)returnsintervalyearforCustomerTypebeginreturnonDate-self.dateOfBirth;endWecannowfindtheageofeachcustomer:selectname.lastname,ageOnDate(current_date)fromcustomer©Silberschatz,KorthandSudarshan,BoZhou1.8DatabaseSystemConceptsInheritanceSupposethatwehavethefollowingtypedefinitionforpeople:createtypePerson(namevarchar(20),addressvarchar(20))UsinginheritancetodefinethestudentandteachertypescreatetypeStudentunderPerson(degreevarchar(20),departmentvarchar(20))createtypeTeacherunderPerson(salaryinteger,departmentvarchar(20))Subtypescanredefinemethodsbyusingoverridingmethodinplaceofmethodinthemethoddeclaration©Silberschatz,KorthandSudarshan,BoZhou1.9DatabaseSystemConceptsMultipleInheritanceSQL:1999andSQL:2003donotsupportmultipleinheritanceIfourtypesystemsupportsmultipleinheritance,wecandefineatypeforteachingassistantasfollows:createtypeTeachingAssistantunderStudent,TeacherToavoidaconflictbetweenthetwooccurrencesofdepartmentwecanrenamethemcreatetypeTeachingAssistantunderStudentwith(departmentasstudent_dept),Teacherwith(departmentasteacher_dept)©Silberschatz,KorthandSudarshan,BoZhou1.10DatabaseSystemConceptsConsistencyRequirementsforSubtablesConsistencyrequirementsonsubtablesandsupertables.Eachtupleofthesupertable(e.g.people)cancorrespondtoatmostonetupleineachoftheimmediatesubtables(e.g.studentsandteachers)Thatis,nooverlapamongsubtables.AdditionalconstraintinSQL:1999:Alltuplescorrespondingtoeachother(thatis,withthesamevaluesforinheritedattributes)mustbederivedfromonetuple(insertedintoonetable).Thatis,eachentitymusthaveamostspecifictypeWecannothaveatupleinpeoplecorrespondingtoatupleeachinstudentsandteachers©Silberschatz,KorthandSudarshan,BoZhou1.11DatabaseSystemConceptsArrayandMultisetTypesinSQLExampleofarrayandmultisetdeclaration:createtypePublisheras(namevarchar(20),branchvarchar(20))createtypeBookas(titlevarchar(20),author-arrayvarchar(20)array[10],pub-datedate,publisherPublisher,keyword-setvarchar(20)multiset)createtablebooksofBookSimilartothen
本文标题:数据库系统概念PPT第九章,对应原版教材第五版
链接地址:https://www.777doc.com/doc-3603115 .html