15
Object-Based Databases Jose Reyes Jose

Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Embed Size (px)

Citation preview

Page 1: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Object-Based Databases

Jose Reyes Jose

Page 2: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Overview

• Object-relational data model extends the relational data model by providing a richer type system including complex data types and object orientation

• Database systems based on the object-relation model provide a convenient migration path for users of relational databases who wish to use object-oriented features

Page 3: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Complex Data Types

• Book title

• List of authors

• Publisher

• Set of keywords

Page 4: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

4NF Decomposition

Page 5: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Nested Relation

Page 6: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Structured Types

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 where subtypes can be created

Page 7: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Structured Types cont…

Create table customer( name Name, address Address, dateOfBirth date)

Page 8: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Create type CustomerType as ( name Name, address Address, dateOfBirth date) not finalCreate table customer of CustomerType

Create table customer( name row (firstname varchar(20), lastname varchar(20)) address row (street varchar(20), city varchar(20), zipcode varchar(9)), dateOfBirth date)

Page 9: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Select name.lastname, address.cityFrom customer

Page 10: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

We add a method to a structured type definition: create type CustomerType as ( name Name, address Address, dateOnBirth date) not final method ageOnDate(onDate date) returns interval year

We create the method body separately: create instance method ageOnDate(onDate date) returns interval year for CustomerType begin return onDate -- self.dateOfBirth; end

Page 11: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Select name.lastname, ageOnDate(current_date)From customer

Page 12: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

create function Name(firstname varchar(20), lastname varchar(20))returns Namebegin set self.firstname = firstname; set self.lastname = lastname;end

insert into Customer values (new Name(‘John’, ‘Smith’), new Address(‘20 Main St’, ‘New York’, ‘11001’), date ‘1960-8-22’)

Page 13: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Inheritancecreate type Person (name varchar(20), address varchar(20))

create type Student under Person (degree varchar(20), department varchar(20))create type Teacher under Person (salary integer, department varchar(20))

create type TeachingAssistant under Student with (department as student_dept), Teacher with (department as teacher_dept)

Page 14: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

Conclusion

• object based database simplify complex data types

• the SQL for structuring these data types

• the SQL for methods and inheritance

Page 15: Object-Based Databases Jose Reyes Jose. Overview Object-relational data model extends the relational data model by providing a richer type system including

References

• http://highered.mcgraw-hill.com/sites/0072958863/

• Database System Concepts 5th edition