Title: Inferring the Principal Type and the Schema Requirements of an OQL Query
1Inferring the Principal Type and the Schema
Requirements of an OQL Query
Greek State Scholarships Foundation
National Bank of Greece
- Agathoniki Trigoni and Gavin M. Bierman
- July 2001
2Motivation
- What is a well-typed query?
- Queries addressed against multiple schemata
- Schema reconciliation interoperation
- Semi-structured data
- Generic queries and query definitions
DB/Schema A
DB/Schema B
Query Applications
Query
Query
Query
Query
DB/Schema C
Semi-Structured data
3Objectives
- Inferring the
- Principal Type of an OQL Query
- Minimum Schema Type Requirements
define Dept_Managers (dept) as select e from
Employees e where e.positionmanager and
e.departmentdept select d from Departments
d where count (Dept_Managers (d)) gt 5
Employee Department department String
position Department
Employee int department String
position Departments List (int)
Employee String department String
position Department int id
4Outline
- Motivation ? Schema Heterogeneity
- Objectives Type and Schema Inference of OQL
- Type System of OQL (ODMG 3.0)
- Type Compatibility / Resolving Constraints
- Typing Rules
- Inference Algorithm
- Conclusion
5OQL Type System 1
Initial Type System
Subtyping Relation - Examples
6OQL Type System 2
define q1 as select x from Students as x define
q2 as set ( first ( Students ) ) q1 union q2
Need for extended general types
q1 union q2
from Students
first (Students)
member type of any collection
7Extended Type System
any
nonfunctional
function
atomic
constructor
collection
boolean
orderable
class
struct
set/bag
list/array
string
int/float
char
set
bag
list
array
int
float
Generalisation Specialisation Relationship
8Type Compatibility - Constraints
- Expressive power of OQL
- Complex Type System
Variety of Type Constraints
If q1, q2, q3 have types
q3 q1 union q2
set (q1,q2)
q1 distinct(q2)
q1 q2.
q1 q2 5
etc
9Inference Rules
One rule per OQL construct hence
syntax driven inference algorithm
Type environment
Constraints
Examples
10Resolving Constraints
- Constraint Resolution
- Gradual
- Accumulative
11Type inference Algorithm - Example
select c from Courses as c
where count(c.chapters) gt 10 and
first(c.chapters)Types
?3boolean
Member_Type(?1)?2
Constructor_Member_Type(?2,chapters) ?4
?4?collection(nonfunctional)
Member_Type(?4) ?5
string
?4 ?list/array(?5)
Equality_Compatible(?5,string)
?4 ?list/array(string)
?5 string
IT(q)bag(?2)
12Conclusion
OQL Expressiveness
Type Inference Model
Variety of Constraints
Complex Type System
Heterogeneity in DB Applications
Principal Query Type
Schema Requirements