《数据库系统概念PPT第九章,对应原版教材第五版》由会员分享,可在线阅读,更多相关《数据库系统概念PPT第九章,对应原版教材第五版(28页珍藏版)》请在金锄头文库上搜索。
1、Silberschatz, Korth and Sudarshan, Bo Zhou1.1Database System ConceptsChapter 9: Object-Based DatabasesnComplex Data Types and Object OrientationnStructured Data Types and Inheritance in SQLnTable InheritancenArray and Multiset Types in SQLnObject Identity and Reference Types in SQLnImplementing O-R
2、FeaturesnPersistent Programming LanguagesnComparison of Object-Oriented and Object-Relational DatabasesSilberschatz, Korth and Sudarshan, Bo Zhou1.2Database System ConceptsOverviewnTraditional database applications:HLarge amount of relatively simple type of data;HShort and simple transaction (task);
3、nSome new applications need data management support.HWith complex data type: computer aided design(CAD) and geographical information systems(GIS)4Object-Relational Database system;4Object-Oriented Database System;HWith long and complex tasks: very complex data analysis. 4Data warehouse and Data Mini
4、ngSilberschatz, Korth and Sudarshan, Bo Zhou1.3Database System ConceptsObject-Relational Vs Object OrientednObject-Relational HBased on traditional Relational Data modelHExtend the data model to support complex data type, including object orientation and constructs to deal with added data types.HAll
5、ow attributes of tuples to have complex types, including non- atomic values such as nested relations.HPreserve relational foundations, in particular the declarative access to data, while extending modeling power.HDriven by commercial DBMS vendors. nObject-OrientedHBased on object-oriented programmin
6、g languages, such as C+,Java;HExtend the data persistency feature to the programming language to support data storage and manipulation. Silberschatz, Korth and Sudarshan, Bo Zhou1.4Database System ConceptsComplex Types and SQL:1999nExtensions to SQL to support complex types include: HCollection and
7、large object types4Nested relations are an example of collection types HStructured types4Nested record structures like composite attributes HInheritance HObject orientation4Including object identifiers and referencesnOur description is mainly based on the SQL:1999 standard HNot fully implemented in
8、any database system currently HBut some features are present in each of the major commercial database systems4Read the manual of your database system to see what it supportsSilberschatz, Korth and Sudarshan, Bo Zhou1.5Database System ConceptsStructured Types and Inheritance in SQLnStructured types c
9、an be declared and used in SQLcreate type Name as(firstname varchar(20),lastname varchar(20)finalcreate type Address as(street varchar(20),city varchar(20),zipcode varchar(20) not finalHNote: final and not final indicate whether subtypes can be creatednStructured types can be used to create tables w
10、ith composite attributescreate table customer ( nameName, address Address, dateOfBirth date) nDot notation used to reference components: name.firstnameSilberschatz, Korth and Sudarshan, Bo Zhou1.6Database System ConceptsStructured Types (cont.)nUser-defined row typescreate type CustomerType as (name
11、 Name,address Address,dateOfBirth date)not finalnCan then create a table whose rows are a user-defined typecreate table customer of CustomerTypeSilberschatz, Korth and Sudarshan, Bo Zhou1.7Database System ConceptsMethodsnCan add a method declaration with a structured type.method ageOnDate (onDate da
12、te)returns interval yearnMethod body is given separately.create instance method ageOnDate (onDate date)returns interval yearfor CustomerTypebeginreturn onDate - self.dateOfBirth;endnWe can now find the age of each customer:select name.lastname, ageOnDate (current_date)from customerSilberschatz, Kort
13、h and Sudarshan, Bo Zhou1.8Database System ConceptsInheritancenSuppose that we have the following type definition for people:create type Person(name varchar(20),address varchar(20)nUsing inheritance to define the student and teacher types create type Studentunder Person(degree varchar(20),department
14、 varchar(20)create type Teacherunder Person(salary integer,department varchar(20)nSubtypes can redefine methods by using overriding method in place of method in the method declarationSilberschatz, Korth and Sudarshan, Bo Zhou1.9Database System ConceptsMultiple InheritancenSQL:1999 and SQL:2003 do no
15、t support multiple inheritancenIf our type system supports multiple inheritance, we can define a type for teaching assistant as follows: create type Teaching Assistantunder Student, TeachernTo avoid a conflict between the two occurrences of department we can rename them create type Teaching Assistan
16、tunder Student with (department as student_dept ),Teacher with (department as teacher_dept )Silberschatz, Korth and Sudarshan, Bo Zhou1.10Database System ConceptsConsistency Requirements for SubtablesnConsistency requirements on subtables and supertables.HEach tuple of the supertable (e.g. people) can correspond to at most one tuple in each of the immediate subtables (e.g. students and teachers)4That is, no overlap