raju-ordbms
TRANSCRIPT
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 1/36
Object Oriented & Object RelationalDatabases
Ranga Raju VatsavaiTeaching Mentor (Prof. Shekhar)
CSci 5708 : Architecture and Implementation of Database Management Systems, Fall 2003
Week 15 (11/24, 11/26/03) Lecture Notes
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 2/36
Outline for today11/24/03
Objectives Introduction
Need for OO/OR-DBMS
OO Fundamentals How (OO)DBMS incorporates OO ideas
Database Modeling/Querying
Conclusions
OODBMS ORDBMS
Conceptual ODL/UML EER/PEER
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 3/36
Outline for next class 11/26/03
Objectives ORDBMS Fundamentals
How ORDBMS incorporates OO ideas Mapping Conceptual Model into
Logical Model OQL vs. SQL-99
Comparison of OODBMS andORDBMS Conclusions
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 4/36
Learning Objectives
Basic concepts of OO and OR models Extensions at conceptual modeling
Mapping Conceptual Model into LogicalModel
Exposure to additional features in SQL:1999standard.
Ability to model and implement a broaderclass of applications (spatial, multimedia,engineering, biological, scientific, …)
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 5/36
Introduction
Why OODBMS? Let us start with modeling this simple
example in a RDBMS Assume that we are given the following diagram
0,0
1
2
34
5
6 7
8
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 6/36
Introduction – MotivatingExample
Our objective is to store this graph in aRDBMS and support queries on these simplegeometries What kind of relations we need? Print names of rectangles which are squares Find all objects which are inside the rectangle 7.
0,
0
1
2
34
5
67
8
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 7/36
Introduction – Motivating Example
Relations POINT(pname, x, y), EDGE(ename, aPoint),
RECTANGLE(rname, anEdge).
0,
0
1
2
34
5
67
8
r5 e1
r5 e2
r5 e3
r5 e4
e1 p1
e1 p2
e2 p2
e2 p3
e3 p3
e3 p4
e4 p4
e4 p1
p1 3 4
p2 3 10
p3 10 10
p4 10 4
RECTANGLE
EDGEPOINT
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 8/36
Introduction – Motivating Example
Logical Flow
Edge e1 Edge e2
E1.ename = e2.enameE1.aPoint <> e2.aPoint
Edge_Pnt_List (eName, stPnt, endPnt)Point p1
Point p2
Edge_length (eName, eLength)
Rectangle r
rname
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 9/36
Introduction – MotivatingExample
CREATE VIEW pnt_list (ename, stPnt, endPnt)
AS SELECT e.ename, e1.aPoint, e2.aPoint
FROM edge e1, edge e2WHERE e1.ename = e2.ename
AND e1.aPoint <> e2.aPoint;
CREATE VIEW edge_length (ename, elength)
AS SELECT e.ename, sqrt(sq(p1.x –p2.x) + sq(p1.y – p2.y)FROM pnt_list e, point p1, point p2
WHERE e.stPnt = p1.pname
AND e.endPnt = p2.pname;
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 10/36
Introduction – MotivatingExample
Discussion Question –
Print the square names
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 11/36
Introduction – MotivatingExample
Solution
SELECT r.rname
FROM rectangle r, edge_length e
WHERE r.anEdge = e.ename
GROUP BY r.rname
HAVING max(e.elength) ~ MIN (e.elength);
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 12/36
Introduction
Though we can model and query these simplegeometric objects, its Not clean
Complexity increases with complex objects (like irregularpolygons)
Even with these simple objects, how do you answer querieslike ‘find nearest objects to point 2’ or ‘find all intersectingobjects’
What is lacking Support for complex data types Support for predicates (e.g., area, intersect, length)
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 13/36
OODBMS-Fundamentals
Has its origin in OO programming languages
Object State – current value Behavior - what operations are permitted
Difference between PL Object and DB Object PL – Objects exist only during program execution
(transient objects).
DB – Objects persist beyond program termination;stored permanently on a secondary storage DB – allows sharing of objects among multiple
programs and applications
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 14/36
OODBMS-Fundamentals
OID – unique system generated objectidentifier for each object Compare this with RDBMS primary key
Object structure Arbitrarily complex in order to contain all
necessary information about the object Compare this with RDBMS
(rectangle object) – information about complexobject is often scattered
The state of complex object may be constructedfrom other objects using type constructors
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 15/36
OODBMS-Fundamentals
Type constructors Basic – atom, tuple, and set Others – list, bag, and array (collection/bulk types) tuple – also called as a structured type
Formally an object can be thought of as atriple (I,C,V) I – OID C – type constructor V – object state (current value)
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 16/36
OODBMS-Fundamentals
Examples o
1= (i
1, atom, ‘Pen-Chung Yew’)
o2= (i
2, atom, ‘Minneapolis’)
o3= (i
3, atom, ‘Computer Science’)
o4= (i
4, set, {i
1,i
2,i
3})
o5= (i
4, tuple, <DNAME:i
3, DCHAIR:i
1>)
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 17/36
OODBMS-Fundamentals
Type hierarchies and Inheritance OODB permits definition of new types based on other
predefined types, leading to a type hierarchy
Example TYPE_NAME: function, function, …, function
PERSON: firstName, lastName, dob, SSN
STUDENT: firstName, lastName, dob, SSN, status, GPA
FACULTY: firstName, lastName, dob, SSN, rank, salary
STUDENT subtype_of PERSON: major, GPA
FACULTY subtype_of PERSON: rank, salary
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 18/36
OODBMS-Fundamentals
Exercise: Consider the geometry objectsdefined in our first example and definedclass hierarchies
0,0
1
2
34
5
6 7
8
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 19/36
OODBMS-Fundamentals
example - GEOMETRY_OBJECT: Shape, Area, ReferencePoint RECTANGLE subtype-of GEOMETRY_OBJECT
(Shape=‘rectangle’): edge1, edge2, edge3, edge4
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 20/36
OODBMS-Fundamentals
Standards: ODMG Made up of several parts
Object Model Object Definition Language (ODL) Object Query Language (OQL) Binding to OO programming languages (C++,
Smalltalk, Java)
OOBMS O2 ObjectStore Jasmine
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 21/36
Database Modeling
Enhance Entity Relationship (EER – Chap 4,Elmasri/Navathe)
Pictogram Enhanced Entity Relationship(PEER – Chapter 2, SD A Tour). Unified Modeling Language (UML) Object Definition Language
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 22/36
Database Modeling
Example We use two examples (school-DB) and park-DB
(from SDB-A Tour).
Identify typical objects (and hierarchies) in school-DB Person, Student, Faculty, Department
Identify relationships 1:1, 1:M, M:N, partial participation, …
Let us start with EER Includes all the modeling concepts of ER Additionally includes oo concepts of – subclass,
superclass, specialization and generalization,attribute and relationship inheritance
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 23/36
Database Modeling - EER
PersonSSN firstNam
e
d
Student Faculty
Department
major worksin
1 1
NN
status rank
dob
lastName
code name
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 24/36
Database Modeling - EER
Find a suitable entity and define aoverlapping type of relationship
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 25/36
Database Modeling - UML
Person
SSN
dob
firstName
lastName
Department
Code
Name
Student
status
Faculty
rank
* *
{disjoint, mandatory}
deptmajor
1
1
majorsIn worksIn
0..1chair
chairOf
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 26/36
Database Modeling - PEERExactly one
Many (0 or More)
Optional (0 or One)
One or More
Numerically Specified
AggregationInheritance
Derived Class
1+
OGC-Geometry
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 27/36
Database Modeling - PEER
State Park (ER Model)
River RoadCrosses
Name Length Geometry Name NoOfLanes
Geometrysupplies
Volume
Facility Forest Forest_Stand
Fire_StationFire_Image
Name
Geometry
Belongs_to
within
Name
Elevation
accessGeometry
Stand-id
Geometry
Specie
Part_of
capturesmanages
Name Geometry Image-id Image
1 1
M1
N
MM
N
1 M
1
MM
N
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 28/36
Database Modeling - PEER
Pictogram : miniature version of geographic object inserted inside of a
box Entity pictograms Relationship pictograms
Advantages Ease of use Complete grammar Translation rules Pictogram inserted ER diagram to SQL3 level
constructs
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 29/36
Database Modeling - PEER
Pictograms
<Pictogram> <Shape>
* // any possible shape
! // user-defined shapes
<Shape> <Basic Shape>
<Multi-Shape><Derived Shape>
<Alternate Shape>
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 30/36
Database Modeling - PEER
<BasicShape> PolygonPoint Line
Pictograms for Basic Shapes
Pictograms for Multi-Shapes
0, nn
<Cardinality>
0,1
1
1,n
0,n
n
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 31/36
Database Modeling - PEER
<Derived Shape>
Pictograms for Derived
Shapes
Pictograms for Alternate
Shapes
<Basic Shape>
<Basic Shape><Basic Shape>
<Basic Shape><Derived Shape>
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 32/36
Database Modeling - PEER
Any Possible Shape *
!Raster TIN Thesian
Pictograms for Raster
Shapes
Pictograms for
Relationships
Part_of (Network) Part_of (Partition)
User Defined Shape
Raster Shape Raster TIN
Thesian
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 33/36
Database Modeling - PEER
State Park (PEER)
River RoadCrosses
Name Length Name NoOfLanes
supplies
Volume
Facility Forest Forest_Stand
Fire_Station Fire_Image
Name
Belongs_to
NameElevation
access
Stand-id Specie
Part_of
capturesmanages
Name Image-id
1 1
N
MM
N
1 M
1
MM
N
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 34/36
Summary and Conclusions
Learning Objectives Understand OO Concepts Conceptual Modeling
RDBMS limitations No support for complex data types and predicates
OO Rich set of features – encapsulation, inheritance, ..
Helps manage complexity Conceptual Modeling – Simple Extensions
EER, UML, PEER
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 35/36
Next Week
ORDMBS (SQL-3) in depth Mapping of Conceptual Model onto
ORDBMS (SQL-3 DDL constructs) Examples using Postgresql/PostGIS Comparison of OODBMS and ORDBMS Conclusions
8/4/2019 raju-ordbms
http://slidepdf.com/reader/full/raju-ordbms 36/36
Additional Readings
http://www.cs.umn.edu/~vatsavai/oo-ordbms.ppt
Main – Database Management Systems byRaghu Ramakrishnan (Chapter 24: Object
Database Systems). Additional References (relevant chapters):
Fundamentals of Database Systems – Elmasri &Navathe
A First Course In Database Systems – Ullman & Widom. http://www-users.cs.umn.edu/~shekhar/5705/
Spatial Database – A Tour (Chapter 2 and 3)