Type System for an Object-Oriented Database Programming Language Yuri Leontiev [email protected]...

23
Type System for an Object-Oriented Database Programming Language Yuri Leontiev [email protected] http://www.cs.ualberta.ca/~yuri University of Alberta Edmonton, Alberta Canada T6G 2H1
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    240
  • download

    1

Transcript of Type System for an Object-Oriented Database Programming Language Yuri Leontiev [email protected]...

Type System for an Object-Oriented Database

Programming Language

Yuri [email protected]

http://www.cs.ualberta.ca/~yuri

University of AlbertaEdmonton, AlbertaCanada T6G 2H1

2

OODBPLs

The concept of an OODBPL

Object-OrientedProgramming Languages

Persistent (Database)Programming Languages

Object-OrientedDatabase Systems

3

Requirement Summary

VerifiabilityDecidabilitySubstitutabilityMulti-methodsMutable typesParametric types

4

Language Comparison

Language

C++JavaPizzaSatherCecilMini-CecilTransframeMLMLPolyTOILTIGUKAT

Theory

D/USD/USD/SD/S

D/USUD?/SD/USD/SD/SD/SD/S

Subst.(5)

34055555555

Param.(5)

20333542325

Multi-m.(5)

0000555

n/a505

Mutable(5)

55555553355

Tests(30)

56111816272512161630

5

Behaviors

Types

Functions

Classes

3-Layer Design

Implementationfunctions

Implementationtypes

Structure

Functionality

6

_xCenter;_yCenter;_width;

_height;_radius

Extends

Types and Classes

xCenter;yCenter;intersects(T_Shape)

height;width;

radius;

T_Shape

T_Rectangle T_Circle

T_Point

Subtypes

C_PointC_Rectangle C_Circle

Implements

7

Multi-methods

T_Shape s1, s2;s1 := aRectangle1; s2 := aRectangle2; s1.intersects(s2) // fRRs1 := aRectangle; s2 := aCircle; s1.intersects(s2) // fRCs1 := aCircle; s2 := aPoint; s1.intersects(s2) // fCP

xCenter; yCenterintersects(T_Shape)

T_Shape

height; width;intersects(T_Rectangle) :: fRRintersects(T_Circle) :: fRCintersects(T_Point) :: fRP

T_Rectangleradius;intersects(T_Circle) :: fCCintersects(T_Rectangle) :: fCRintersects(T_Point) :: fCP

T_Circle

intersects(T_Point) :: fPPintersects(T_Rectangle) :: fPRintersects(T_Circle) :: fPC

T_Point

Subtypes

8

Attributes

T_Natural _age; T_String _name;age implementation _age;name implementation _name;

T_Natural _age; T_String _firstName, _lastName, _middleName;age implementation _age;name implementation fun() { return _firstName + ‘ ‘ + _lastName + ‘ ‘ + _middleName; }set_name implementation fun(arg) { _firstName := arg.extractToken(2,’ ’); _lastName := arg.extractToken(3,’ ’); _middleName := arg.extractToken(1,’ ’); }

age :=: T_Natural;name :=: T_String;

T_Person

C_Person

Implements

C_Person3N

T_Person aPerson;aPerson := new C_Person; aPerson.name := “S. John Smith”;aPerson := new C_Person3N; aPerson.name := “S. John Smith”;aPerson.name.print;

9

Parametric Types

get : X;

T_InputStream(covar X)

put(X);

T_OutputStream(contravar X)

T_IOStream(novar X)

Subtypes

T_InputStream(T_Person) ip; T_InputStream(T_Student) is;ip.get.age.print; ip := is; ip.get.age.print; is.get.studentId.print;T_Person aPerson; T_Student aStudent;T_OutputStream(T_Person) op; T_OutputStream(T_Student) os;op.put(aPerson); op.put(aStudent); os.put(aStudent); os.put(aPerson)T_IOStream(T_Student) ios;ip := ios; os := ios; ios.get.studentId.print; op := ios;

10

ComparisonsT_Ordered(T_Numeric)

less(T_Ordered(X)) : T_Boolean;greater (T_Ordered(X)) : T_Boolean implementation fun(arg) { return not arg.less(self); }

T_Ordered(contravar X)

T_Numeric

T_Real

T_Integer

T_Ordered(T_Date)

T_Date

(5.0).less(6); 3.less(3.35); ‘2/3/98’.less(‘3/4/97’);’2/3/98’.less(3);

11

Constrained Types

sort() : T_List(X) where (X subtypes T_Ordered(X));

T_Set(covar X)

T_Set(T_Integer) iSet;T_List(T_Integer) iList;iList := iSet.sort; // If iSet was {4,3,5}, // iList will be <3,4,5>T_Set(T_Person) pSet; T_List(T_Person) pList;pList := pSet.sort;

12

Functional Types

sort() : T_List(X) where (X subtypes T_Ordered(X));genericSort( (X,X):T_Boolean ) : T_List(X);

T_Set(covar X)

T_Set(T_Integer) iSet;T_List(T_Integer) iList;iList := iSet.genericSort( fun(x,y) { return x.less(y) } );T_Set(T_Person) pSet; T_List(T_Person) pList;pList := pSet.genericSort( fun(x,y) { return x.age.less(y.age); } );

13

Typechecking

Local monotonicityConsistency of the user type graphConstraint consistencyGlobal behavior consistencyFunctional consistencyDispatch consistency

– coverage– unambiguity– correctness

14

Theory: Types

Model: regular trees = T_List()

Ground types– T_Integer, T_List(T_Integer),

(T_Real,T_Integer) T_Integer

Simple constrained types– ( T_Integer).( )

Constrained types– glb(( T_Integer).( ) ,T_Date T_Date)

15

Theory: Entailment

Constraint sets

– C = { L1 U1, L2 U2,...,Ln Un}

Entailment of constraint sets– C1[1,…,n] |-- C2[1,…, n,1,... ,n] iff

1,…, n : C1[1,…, n] 1,... ,n : C2[1,…, n,1,... ,n]

– (T_Set(1) T_Set(2)) |-- 1 2

16

Theory: Subtyping

Subtyping of simple constrained types

– (C1).A1 (C2).A2 iff C2 |-- C1 & (A1 A2)

– ((T_Set(T_Integer) T_Set(1)).1) T_Integersince |-- T_Set(T_Integer) T_Set(1) & 1 T_Integer(let 1 = T_Integer)

17

Contributions

Compiled a comprehensive list of OODBPL type system requirements

Designed a type system that satisfies the requirements

Developed decidable typechecking algorithms

Developed a theory capable of expressing all the type system features

Proved decidability and correctness of the resulting system

18

Future Research

Design issues:– Language design– Persistence model

Implementation issues:– Type checker– Compiler– Optimization

Theoretical issues:– Relaxing user type graph constraints

19

Questions?

20

Type System Features

VerifiabilityDecidabilityTransparencyExtensibility

21

OOPL Requirements

Inheritance: – interface – implementation

Method typesMethod uniformityReflexivity

22

DBPL Requirements

Persistence independenceUser-defined type constructorsEncapsulationParametric typesPartial type specificationIncremental type checkingTypability of SQL-like queriesMutable object types

23

OODB Requirements

Orthogonal type constructorsExtensibility & interoperabilityView mechanismDynamic schema evolution