Download Object-Based Databases by Jose Reyes Jose

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Entity–attribute–value model wikipedia , lookup

Database wikipedia , lookup

Clusterpoint wikipedia , lookup

PL/SQL wikipedia , lookup

Functional Database Model wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
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
and object orientation
• Database systems based on the objectrelation model provide a convenient migration
path for users of relational databases who
wish to use object-oriented features
Complex Data Types
•
•
•
•
Book title
List of authors
Publisher
Set of keywords
4NF Decomposition
Nested Relation
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
Structured Types cont…
Create table customer(
name Name,
address Address,
dateOfBirth date)
Create 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)
Select name.lastname, address.city
From customer
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
Select name.lastname, ageOnDate(current_date)
From customer
create 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’)
Inheritance
create 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)
Conclusion
• object based database simplify complex
data types
• the SQL for structuring these data types
• the SQL for methods and inheritance
References
• http://highered.mcgrawhill.com/sites/0072958863/
• Database System Concepts 5th edition