Title: Object-Based Databases
1Object-Based Databases
2Overview
- 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
3Complex Data Types
- Book title
- List of authors
- Publisher
- Set of keywords
44NF Decomposition
5Nested Relation
6Structured Types
Create type Address as (street varchar(20),
city varchar(20), zipcode
varchar(20)) not final
Create type Name as (firstname varchar(20),
lastname varchar(20)) final
Note final and not final indicate where
subtypes can be created
7Structured Types cont
Create table customer( name Name, address
Address, dateOfBirth date)
8Create type CustomerType as ( name Name,
address Address, dateOfBirth date) not
final Create 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)
9Select name.lastname, address.city From customer
10 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
11Select name.lastname, ageOnDate(current_date) From
customer
12create function Name(firstname varchar(20),
lastname varchar(20)) returns Name begin 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)
13Inheritance
create type Student under Person (degree
varchar(20), department varchar(20)) create
type Teacher under Person (salary integer,
department varchar(20))
create type Person (name varchar(20),
address varchar(20))
create type TeachingAssistant under Student
with (department as student_dept),
Teacher with (department as teacher_dept)
14Conclusion
- object based database simplify complex data types
- the SQL for structuring these data types
- the SQL for methods and inheritance
15References
- http//highered.mcgraw-hill.com/sites/0072958863/
- Database System Concepts 5th edition