Presentation is loading. Please wait.

Presentation is loading. Please wait.

E.Bertino, L.Matino Object-Oriented Database Systems Chapter 3. Query Language Seoul National University Department of Computer Engineering OOPSLA Lab.

Similar presentations


Presentation on theme: "E.Bertino, L.Matino Object-Oriented Database Systems Chapter 3. Query Language Seoul National University Department of Computer Engineering OOPSLA Lab."— Presentation transcript:

1 E.Bertino, L.Matino Object-Oriented Database Systems Chapter 3. Query Language Seoul National University Department of Computer Engineering OOPSLA Lab.

2 OOPSLA Lab 2 CONTENTS 4 Basic Concept 4 Query Language 4 Impedance Mismatch 4 Characteristics of OO Query Language 4 An SQL-like Query Language in ORION 4 The Languages of GemStone, O 2, and Iris

3 OOPSLA Lab 3 Query Language 4 Requirements 4 high-level 4 declarative (  procedural) 4 efficient 4 application independent 4 Resource completeness 4 Computational completeness 4 not so obvious for DB 4 query language with reasonable interface using P/L

4 OOPSLA Lab 4 Impedance Mismatch 4 Difference between the type system of P/L and that of DBL such as DDL, DML 4 Impedance mismatch in relational system 4 two different type system 4 two different computational model 4 Reasons to overcome impedance mismatch 4 to integrate the form between the languages involved 4 to increase the programmer’s productivity 4 One solution 4 adapting the programming models to be DML

5 OOPSLA Lab 5 Good Query Language Model 4 Simple but powerful 4 Not yet proposed 4 complex data model with poor formal foundation 4 query language and encapsulation are inconsistent 4 Seamlessness 4 smooth transition between two language environments

6 OOPSLA Lab 6 Characteristics of OO Query Language 4 Access to Objects 4 Aggregation Hierarchy 4 Inheritance Hierarchy 4 Recursive Queries 4 Methods 4 Query Results

7 OOPSLA Lab 7 Access to Objects 4 In RDBMS 4 only by query language 4 In OODBMS 4 by navigation using OID 4 by SQL-like query languages 4 by hybrid methods 1. set of OIDs using SQL-like query language 2. navigation for each OID 4 Types of equality in semantics of query 4 identity equality vs. value equality

8 OOPSLA Lab 8 Aggregation hierarchies 4 Attributes in a query can be nested 4 navigation is advantageous 4 Explicit join by identity equality operator 4 Implicit join by path expression 4 to navigate easily through aggregation hierarchy 4 no more expressive power but more conceptual conciseness w  Project  g  Task  i  Researcher  w.Workplan = g  g.Leader = i  i.Specialization = “DB” w  Project  g  Task  i  Researcher  w.Workplan = g  g.Leader = i  i.Specialization = “DB” w  Project  w.Workplan.Leader.Specialization = “DB”

9 OOPSLA Lab 9 Inheritance Hierarchies 4 A class or a class and all subclasses can be queried 4 Alternative predicate if class(x) = C 1 then pred 1 if class(x) = C 2 then pred 2 if class(x) = C 3 then pred 3... if class(x) = C n then pred n if class(x) = C 1 then pred 1 if class(x) = C 2 then pred 2 if class(x) = C 3 then pred 3... if class(x) = C n then pred n

10 OOPSLA Lab 10 Recursive Queries 4 A branch in a hierarchy of classes is cyclic, if given classes C i, C j meet one of the followings 4 C j is the (indirect) domain of an attribute of C i and C i is the domain of an attribute of C j 4 C j is the (indirect) domain of an attribute of C i and a superclass or subclass of C i is the domain of an attribute of C j

11 OOPSLA Lab 11 Types of Cyclic Branches Type n Type sType s-s Type n-s Key Attribute/domain Class/superclass

12 OOPSLA Lab 12 Methods 4 Methods can be used in queries 4 derived attribute a function which returns object comparable with that of an attribute primitive value or OID 4 predicate method a function which returns Boolean value true or false

13 OOPSLA Lab 13 Query Results 4 In relational model 4 the result of a query is a relation 4 nested queries 4 In OO model, restrictions on projection 4 the object itself or a single attribute 4 a set of object instances of a general class 4 in ORION, only limited forms of projection to both an attribute and path expression of objects

14 OOPSLA Lab 14 An SQL-like Language in ORION 4 Overview 4 Single Operand Queries 4 Multiple Operand Queries 4 Operations on Sets

15 OOPSLA Lab 15 SimpleQuery ::= select TargetClause | select TargetClause from RangeClause | select TargetClause where QualificationClause | select TargetClause from RangeClause where QualificationClause SimpleQuery ::= select TargetClause | select TargetClause from RangeClause | select TargetClause where QualificationClause | select TargetClause from RangeClause where QualificationClause Overview of an SQL-like Language 4 Defined for ORION 4 Syntax for simple query 4 TargetClause(select) for attributes to be retrieved 4 RangeClause(from) for sets of class instances 4 QualificationClause(where) for predicates

16 OOPSLA Lab 16 select:T fromTask :T where:T man_year == 2 and:T leader specialization == ‘DB’ and:T participant leader specialization == ‘Information System’. select:T fromTask :T where:T man_year == 2 and:T leader specialization == ‘DB’ and:T participant leader specialization == ‘Information System’. selectfromTask whereman_year == 2 andleader specialization == ‘DB’ andparticipant leader specialization == ‘Information System’. selectfromTask whereman_year == 2 andleader specialization == ‘DB’ andparticipant leader specialization == ‘Information System’. Examples of Simple Query 4 Object variables 4 reference the instances of classes 4 specified in RangeClause

17 OOPSLA Lab 17 Single Operand Queries 4 Acyclic queries 4 Cyclic queries 4 Use of methods 4 derived attributes 4 predicate attributes 4 Query results

18 OOPSLA Lab 18 Acyclic Queries 4 Aggregation hierarchy 4 path expression for nested sequences of attributes 4 Relation operators for multiple-valued attributes 4 has-subset, is-subset, =, is-in, union, difference, etc. 4 Inheritance hierarchy 4 the scope of a query can include inheritance hierarchy 4 `*' operator after the name of the class select Document* difference TechnicalReport where classification = ‘C2’ select Document* difference TechnicalReport where classification = ‘C2’

19 OOPSLA Lab 19 select Technical_Report (recurses amendment_to) where acronym_document == ‘ZZ122’ select Technical_Report (recurses amendment_to) where acronym_document == ‘ZZ122’ select Project where exist participating leader specialization == ‘DB’ select Project where exist participating leader specialization == ‘DB’ select Project where reserved_project select Project where reserved_project select Project project_name, work_plan where recurses subproject reserved_project select Project project_name, work_plan where recurses subproject reserved_project Several Query Types 4 Cyclic query 4 Derived attribute 4 Predicate method 4 Projections to the nested and simple objects

20 OOPSLA Lab 20 JoinPredicate ::= ScalarVariable ScalarOperator ScalarVariable | SetVariable SetOperator SetVariable JoinPredicate ::= ScalarVariable ScalarOperator ScalarVariable | SetVariable SetOperator SetVariable Multiple Operand Queries 4 Explicit join between classes 4 Syntax 4 Example select :D from Document :D, Project :P where :D title = :P Project_name select :D from Document :D, Project :P where :D title = :P Project_name

21 OOPSLA Lab 21 Operations on Sets 4 object membership based on value equality 4 Union, Intersection, Difference 4 object membership based on identity equality 4 UnionOfValue, DifferenceOfValue, IntersectionOfValue

22 OOPSLA Lab 22 GemStone 4 Querying only on collection object of Set class 4 Queries are issued by 4 select message for selecting all satisfied objects 4 reject message for selecting all unsatisfied objects 4 detect message for selecting an satisfied object 4 Query result 4 a set of objects whose class is the same as queried one Tasks select: { :t | (t.man_years > 20) & (t.leader.specialization = ‘DB’) } Tasks select: { :t | (t.man_years > 20) & (t.leader.specialization = ‘DB’) }

23 OOPSLA Lab 23 select t from t in Task where t.man_year > 20 and t.leader.specialization == ‘DB’ select t from t in Task where t.man_year > 20 and t.leader.specialization == ‘DB’ O2O2 4 Only standalone query language 4 can’t be used within methods or CO 2 language 4 Interactive graphic interface for 4 formulating queries 4 saving the queries 4 assigning a name to queries 4 browsing the result 4 Projections, joins, and sub-queries

24 OOPSLA Lab 24 Iris 4 OSQL query language 4 most similar to the SQL in terms of functionality 4 cursor for accessing the query results sequentially 4 Methods can be invoked in queries 4 Projection and distinct clause are possible select t for each Task t where t.man_year > 20 and t.leader.specialization = ‘DB’ ; select t for each Task t where t.man_year > 20 and t.leader.specialization = ‘DB’ ;


Download ppt "E.Bertino, L.Matino Object-Oriented Database Systems Chapter 3. Query Language Seoul National University Department of Computer Engineering OOPSLA Lab."

Similar presentations


Ads by Google