Chapter 9:Object-Based Databases Complex Data Types and Object Orientation Structured Data Types and Inheritance in SQL Table Inheritance Array and Multiset Types in SQL Object Identity and Reference Types in SQL Implementing O-R Features Persistent Programming Languages Comparison of Object-Oriented and Object-Relational Databases Database System Concepts-5th Edition,Aug 9,2005. 9.2 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 9.2 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Chapter 9: Object-Based Databases Complex Data Types and Object Orientation Structured Data Types and Inheritance in SQL Table Inheritance Array and Multiset Types in SQL Object Identity and Reference Types in SQL Implementing O-R Features Persistent Programming Languages Comparison of Object-Oriented and Object-Relational Databases
Object-Relational Data Models Extend the relational data model by including object orientation and constructs to deal with added data types. Allow attributes of tuples to have complex types,including non-atomic values such as nested relations. Preserve relational foundations,in particular the declarative access to data,while extending modeling power. Upward compatibility with existing relational languages. Database System Concepts-5th Edition,Aug 9,2005. 9.3 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 9.3 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Object-Relational Data Models Extend the relational data model by including object orientation and constructs to deal with added data types. Allow attributes of tuples to have complex types, including non-atomic values such as nested relations. Preserve relational foundations, in particular the declarative access to data, while extending modeling power. Upward compatibility with existing relational languages
Complex Data Types Motivation: Permit non-atomic domains (atomic indivisible) Example of non-atomic domain:set of integers,or set of tuples Allows more intuitive modeling for applications with complex data Intuitive definition: allow relations whenever we allow atomic(scalar)values -relations within relations Retains mathematical foundation of relational model Violates first normal form. Database System Concepts-5th Edition,Aug 9,2005. 9.4 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 9.4 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Complex Data Types Motivation: Permit non-atomic domains (atomic indivisible) Example of non-atomic domain: set of integers,or set of tuples Allows more intuitive modeling for applications with complex data Intuitive definition: allow relations whenever we allow atomic (scalar) values — relations within relations Retains mathematical foundation of relational model Violates first normal form
Example of a Nested Relation Example:library information system Each book has title, a set of authors, Publisher,and a set of keywords Non-1NF relation books title author-set publisher keyword-set (name,branch) Compilers (Smith,Jones) (McGraw-Hill,New York) [parsing,analysis) Networks Jones,Frick) (Oxford,London) (Internet,Web} Database System Concepts-5th Edition,Aug 9,2005. 9.5 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 9.5 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Example of a Nested Relation Example: library information system Each book has title, a set of authors, Publisher, and a set of keywords Non-1NF relation books
4NF Decomposition of Nested Relation Remove awkwardness of flat-books by assuming that the following multivalued dependencies hold: title _author title_keyword title pub-name,pub-branch Decompose flat-doc into 4NF using the schemas: (title,author) (title,keyword (title,pub-name,pub-branch Database System Concepts-5th Edition,Aug 9,2005. 9.6 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 9.6 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. 4NF Decomposition of Nested Relation Remove awkwardness of flat-books by assuming that the following multivalued dependencies hold: title author title keyword title pub-name, pub-branch Decompose flat-doc into 4NF using the schemas: (title, author ) (title, keyword ) (title, pub-name, pub-branch )
4NF Decomposition of flat-books title author title keyword Compilers Smith Compilers parsing Compilers Jones Compilers analysis Networks Jones Networks Internet Networks Frick Networks Web authors keywords title pub-name pub-branch Compilers McGraw-Hill New York Networks Oxford London books4 Database System Concepts-5th Edition,Aug 9,2005. 9.7 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 9.7 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. 4NF Decomposition of flat–books
Problems with 4NF Schema 4NF design requires users to includejoins in their queries. 1NF relational view flat-books defined by join of 4NF relations: eliminates the need for users to perform joins, but loses the one-to-one correspondence between tuples and documents. And has a large amount of redundancy Nested relations representation is much more natural here. Database System Concepts-5th Edition,Aug 9,2005. 9.8 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 9.8 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Problems with 4NF Schema 4NF design requires users to include joins in their queries. 1NF relational view flat-books defined by join of 4NF relations: eliminates the need for users to perform joins, but loses the one-to-one correspondence between tuples and documents. And has a large amount of redundancy Nested relations representation is much more natural here
Complex Types and SQL:1999 Extensions to SQL to support complex types include: Collection and large object types Nested relations are an example of collection types Structured types Nested record structures like composite attributes Inheritance Object orientation Including object identifiers and references Our description is mainly based on the SQL:1999 standard Not fully implemented in any database system currently But some features are present in each of the major commercial database systems Read the manual of your database system to see what it supports Database System Concepts-5th Edition,Aug 9,2005. 9.9 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 9.9 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Complex Types and SQL:1999 Extensions to SQL to support complex types include: Collection and large object types Nested relations are an example of collection types Structured types Nested record structures like composite attributes Inheritance Object orientation Including object identifiers and references Our description is mainly based on the SQL:1999 standard Not fully implemented in any database system currently But some features are present in each of the major commercial database systems Read the manual of your database system to see what it supports
Structured Types and Inheritance in SQL Structured types can be declared and used in SQL create type Name as (firstname varchar(20), lastname varchar(20)) final create type Address as (street varchar(20), city varchar(20), zipcode varchar(20)) not final Note:final and not final indicate whether subtypes can be created Structured types can be used to create tables with composite attributes create table customer( name Name, addressAddress, dateOfBirth date) Dot notation used to reference components:name.firstname Database System Concepts-5th Edition,Aug 9,2005. 9.10 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 5 9.10 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Structured Types and Inheritance in SQL Structured types can be declared and used in SQL create type Name as (firstname varchar(20), lastname varchar(20)) final create type Address as (street varchar(20), city varchar(20), zipcode varchar(20)) not final Note: final and not final indicate whether subtypes can be created Structured types can be used to create tables with composite attributes create table customer ( name Name, address Address, dateOfBirth date) Dot notation used to reference components: name.firstname
Structured Types (cont.) User-defined row types create type CustomerType as( name Name. address Address. dateOfBirth date) not final Can then create a table whose rows are a user-defined type create table customer of CustomerType Database System Concepts-5th Edition,Aug 9,2005. 9.11 @Silberschatz,Korth and Sudarshan
Database System Concepts - 5 9.11 ©Silberschatz, Korth and Sudarshan th Edition, Aug 9, 2005. Structured Types (cont.) User-defined row types create type CustomerType as ( name Name, address Address, dateOfBirth date) not final Can then create a table whose rows are a user-defined type create table customer of CustomerType