Download - A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Transcript
Page 1: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 1 of 37

Go Back

Full Screen

Close

Quit

A Fuzzy Valid-Time Modelfor Relational DatabasesWithin the Hibernate

FrameworkJose Enrique Pons Olga Pons Capote

Ignacio Blanco MedinaDepartment of Computer Science and Artificial Intelligence

University of Granada, Spain{jpons,opc,iblanco}@decsai.ugr.es

October 22, 2011

Page 2: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 2 of 37

Go Back

Full Screen

Close

Quit

1. Contents

The structure of the presentation is:

• Motivation.

• Context:

– Fuzzy relational databases.

– Temporal databases.

– Fuzzy temporal databases.

– Hibernate.

• Proposal: Fuzzy Valid-Time model for relationaldatabases.

• Conclusions and future work.

Page 3: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 3 of 37

Go Back

Full Screen

Close

Quit

2. Motivation

• Time-related attributes are considered to havean impact on the consistency of the object setmodelled by the database.

• A true standard for fuzzy temporal databasesdoes not exist.

• General model to represent and querying fuzzytemporal types in any relational database.

• Portable implementation within the HibernateFramework.

Page 4: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 4 of 37

Go Back

Full Screen

Close

Quit

3. Context

• 3.1 Fuzzy relational databases (FBD):

– Representation: fuzzy data types.

– Querying: flexible querying.

• 3.2 Temporal databases:

– Time models (valid-time, transaction time,decision time... )

– Temporal operators.

• 3.3 Fuzzy temporal databases:

– Fuzzy Validity Period.

• Hibernate.

Page 5: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 5 of 37

Go Back

Full Screen

Close

Quit

3.1. Fuzzy relational databases

Two main features:

• Fuzzy representation”The restaurant X in the database is cheap inaverage.””The restaurant X in the database is a ham-burguer bar.”

• Flexible querying:”The user wants to obtain a list with cheaprestaurants.”

Page 6: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 6 of 37

Go Back

Full Screen

Close

Quit

3.1.1. Fuzzy data types

Two main types:

• Ordered underlying domain:

1

016 18 24 26

possibility

Cheap Middle-price Expensive

Price

This data type may be represented as a trapezoidin the form: [α, β, γ, δ].E.g. Middle-price = [16, 18, 24, 26]

• Non-ordered underlying domain:Fast food Hamburger Chinese

Fast food 1 0.8 0.6Hamburger 0.8 1 0.2

Chinese 0.6 0.2 1

Page 7: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 7 of 37

Go Back

Full Screen

Close

Quit

3.1.2. Flexible Querying

The user may query with vagueness in the database:”The user want to obtain a list of cheap restau-rants.”

ID Name AVG Quality001 Amadeus [15,10,20,5] 5002 Atlantis [11,5,17,6] 3003 Cafe Theatre [20,10,30,10] 2004 De Graslei [23,18,28,5] 5005 Pakhuis [13,11,15,2] 3006 De 3 Biggetjes [45,25,65,20] 4

1

016 18 24 26

possibility

Cheap Middle-price Expensive

Price

Page 8: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 8 of 37

Go Back

Full Screen

Close

Quit

The selected restaurants are:

ID Name AVG Quality001 Amadeus [15,10,20,5] 5002 Atlantis [11,5,17,6] 3005 Pakhuis [13,11,15,2] 3

Page 9: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 9 of 37

Go Back

Full Screen

Close

Quit

Operators for fuzzy querying:

Possibility Necessity Possibly / NecessarilyFEQ NFEQ Fuzzy =FGT NFGT Fuzzy >

FGEQ NFGEQ Fuzzy ≥FLT NFLT Fuzzy.<

FLEQ NFLEQ Fuzzy ≤MGT NMGT Much >MLT NMLT Much <

FEQ(p1, p2) = supd∈U

min(πp1(d), πp2(d)) (1)

Where U is the underlying domain, p1, p2 are twovalues of a given fuzzy type (e.g. fuzzy type 2) andπp1(d), πp2(d) are the associated possibility distribu-tions.

Page 10: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 10 of 37

Go Back

Full Screen

Close

Quit

Context:

• 3.1 Fuzzy relational databases (FBD):

– Representation: fuzzy data types.

– Querying: flexible querying.

• 3.2 Temporal databases:

– Time models (valid-time, transaction time,decision time... )

– Temporal operators.

• 3.3 Fuzzy temporal databases:

– Fuzzy Validity Period.

Page 11: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 11 of 37

Go Back

Full Screen

Close

Quit

3.2. Temporal Databases:

A temporal database is a database that manages thetime in its schema.Time-related attributes have an impact on the con-sistency of the database.

Page 12: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 12 of 37

Go Back

Full Screen

Close

Quit

Example:

ID Name Year Works for Start Year End Year1 Peter 1987 John 2010 -2 Maria 1978 John 2001 -3 John 1954 - 1999 -4 Sarah 1982 Maria 2005 2009

Consider that ID is the primary key.Problem: If Sarah is hired in 2010, we can notinsert the new tuple.

Page 13: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 13 of 37

Go Back

Full Screen

Close

Quit

Example:

New primary key:

{ ID ∪[ Start Year, End Year ]}

ID Name Year Works for Start Year End Year1 Peter 1987 John 2010 -2 Maria 1978 John 2001 -3 John 1954 - 1999 -4 Sarah 1982 Maria 2005 20094 Sarah 29 Maria 2010 -

Also a consistence mechanism must be defined...

Page 14: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 14 of 37

Go Back

Full Screen

Close

Quit

Example:

Some spurious values might be inserted:

ID Name Year Works for Start Year End Year1 Peter 1987 John 2010 -2 Maria 1978 John 2001 -3 John 1954 - 1999 -4 Sarah 1982 Maria 2005 20094 Sarah 29 Maria 2001 20074 Sarah 1982 Maria 2010 -

Usually, DML sentences (insert, update, delete) arere-defined to ensure consistency.

Page 15: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 15 of 37

Go Back

Full Screen

Close

Quit

3.2.1. Temporal models

• Valid-Time: The time when the fact is true inthe modelled reality.

• Transaction time: The time when the fact isstored in the database.

• Decision-time: The time when an event wasdecided to happen.

• Bi-temporal: Valid and transaction time.

• Tri-temporal: Valid, transaction and decisiontime.

Page 16: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 16 of 37

Go Back

Full Screen

Close

Quit

3.2.2. Temporal operators:

Allen’s temporal relation between intervals:Operator Inverse RepresentationX Before Y After XXX YYY

X Equal Y Equal XXXY Y Y

X Meets Y Meet by XXXYYY

X Overlaps Y Overlap by XXXY Y Y

X During Y Contains XXXY Y Y Y Y Y

X Starts Y Start by XXXY Y Y Y Y Y

X Finishes Y Finished by XXXY Y Y Y Y Y

Page 17: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 17 of 37

Go Back

Full Screen

Close

Quit

Context:

• 3.1 Fuzzy relational databases (FBD):

– Representation: fuzzy data types.

– Querying: flexible querying.

• 3.2 Temporal databases:

– Time models (valid-time, transaction time,decision time... )

– Temporal operators.

• 3.3 Fuzzy temporal databases:

– Fuzzy Validity Period.

– Fuzzy temporal operators.

Page 18: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 18 of 37

Go Back

Full Screen

Close

Quit

3.3. Fuzzy temporal databases:

Page 19: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 19 of 37

Go Back

Full Screen

Close

Quit

3.3.1. Fuzzy Validity Period:

time

time

possibility

possibility

1

1

0

0

VST VETInitial data values

ds-as ds ds+bs de-ae de de+be

d1-a d1 d2 d2+b

S1

S2

α= β= γ= δ=

S1 = S2 ⇒(ds + bs)− (ds − as)

2=d1 − (d1 − a)

2(2)

Where d1 = ds + bs and d2 = de + ae.The FVP is [d1 − a, d1, d2, d2 + b].

Page 20: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 20 of 37

Go Back

Full Screen

Close

Quit

Underlying domain: Julian Day Number (JDN): Acounter which value is incremented in one unit everyday since 1 January 4713 B.C noon.Reasons:

• Representation as unique number

• Simplification of calculations.

Page 21: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 21 of 37

Go Back

Full Screen

Close

Quit

3.3.2. Fuzzy temporal operators:

• BEFORE (I,J) =

1, if Iβ ≤ Jα

Iα−Jβ(Jα−Jβ)−(Iβ−Iα)

, if Iβ > Jα and Iα < Jβ

0, otherwise (Iα ≥ Jβ)

• OVERLAPS (I, J) =

supt

(min (I (t) , J (t)))

• CONTAINS (I, J) =

inft{max (1− I (t) , J (t))}

• EQUALS (I, J) =

min (CONTAINS (I, J) , CONTAINS (J, I)) =

min(inft{max (1− I (t) , J (t))},

inft{max (1− J (t) , I (t))})

Page 22: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 22 of 37

Go Back

Full Screen

Close

Quit

Fuzzy temporal operators implemented in FSQL:

Operator Name FSQL implementationBEFORE (I, J) I FGEQ JOVERLAPS (I, J) I FEQ JEQUALS (I, J) min(I NFEQ J, J NFEQ I)CONTAINS (I, J) I NFEQ J

Page 23: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 23 of 37

Go Back

Full Screen

Close

Quit

3.4. Hibernate Framework

The Hibernate Framework is a collection of opensource projects that enable developers to makeobject-relational mapping. Features:

• Database independent by means of dialects.

• HQL: an object-oriented query language.

• Open source.

Page 24: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 24 of 37

Go Back

Full Screen

Close

Quit

3.4.1. Architecture

An application working with Hibernate has 3 layers:

1. Application layer: CRUD (CReate,Updateand Delete) operations:

(a) Persistent Objects: A current database state.

(b) Transient Objects: These objects do not rep-resent a current database state.

2. Hibernate layer: An abstraction layer be-tween the DBMS and the application.

3. The database: The running DBMS: MySQL,PostgreSQL, Oracle...etc.

Page 25: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 25 of 37

Go Back

Full Screen

Close

Quit

Hibernate Architecture:

HIBERNATE

XML mapping

Application

Persistent Objects

hibernate.

properties

Database

Page 26: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 26 of 37

Go Back

Full Screen

Close

Quit

3.4.2. Querying in Hibernate

1. Query by criteria:createCriteria(Person.class).Add(Restrictions.eq(”login”,”lmmn”));

2. Query by example:Person p.login = ”lmmn”;

3. HQL:Select p from Personal p where p.login =”lmmn”;

4. SQL:Select * from Person as p where p.login =’lmmn’;

Page 27: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 27 of 37

Go Back

Full Screen

Close

Quit

4. Proposal

• Architecture for the general framework for:

– Fuzzy representation.

– Fuzzy querying.

• Implementation within the Hibernate frame-work.

Page 28: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 28 of 37

Go Back

Full Screen

Close

Quit

4.1. Fuzzy Representation

Conditions for portability:

1. The SQL standard is the interface.

2. The fuzzy types are represented in the databaseby basic SQL types.

3. The meta-data for managing properly the ex-tended types relies outside the database catalog.

Page 29: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 29 of 37

Go Back

Full Screen

Close

Quit

4.1.1. Architecture for the general model

The architecture for a generalized object-orientedmodel needs the following elements:

Object-Oriented Layer.

(OORL)

MySQL

Object-Oriented to Relational.

(OO2RL).

O1 ON

R1 RN Relational Layer.

(RRL)

PostgreSQL Oracle

Conversion Layer. (CL)

Page 30: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 30 of 37

Go Back

Full Screen

Close

Quit

4.1.2. Implementation

The model has the following layers:

Application

Fuzzy Data Types Fuzzy Domains Fuzzy

Constraint

ValidatorValues Labels Constraint

Fuzzy Data

Types Adaptor

Fuzzy Domain

Adaptor

Hibernate Core

Database

Type 2 Type 3

Representation

Layer (OORL)

Adaptation

Layer (OO2RRL)

& (RRL)

Conversion

Layer (CL)

F

S

Q

L

Page 31: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 31 of 37

Go Back

Full Screen

Close

Quit

Architecture with the FVP support:

Application

Hibernate FVP

Hibernate FSQL

Hibernate

Database

The Hibernate FSQL allows the representation andquerying of objects with fuzzy attributes.The Hibernate FVP layer allows the use of FuzzyValidity Periods.

Page 32: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 32 of 37

Go Back

Full Screen

Close

Quit

4.2. Fuzzy Querying

The model uses the following elements:

• Declarative implementation for each fuzzyoperator. This implementation should be donein the SQL language.

• Abstract syntax tree (AST) representa-tion for the query. These representation allowsa customization process done by the conversionlayer (CL).

• Conversion Layer: This layer customizes theAST for the running database.

The implementation of the fuzzy querying is done bymodifying the HQL language. The fuzzy operatorsare implemented in a declarative way in the SQLlanguage.

Page 33: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 33 of 37

Go Back

Full Screen

Close

Quit

Query translation:

SELECT

c,c1

Customer

c.fvp c1.fvp

contains

HQL sentence:

"SELECT c

FROM Customer c,

Customer c1

WHERE c.fvp

contains c1.fvp"

SQL sentence

"SELECT *

FROM Customer as c,

Customer as c1

WHERE 1 < CASE WHEN

(c.fvp.gamma <= beta2)

OR (c.fvp.beta >= gamma2) THEN 0

WHEN (c.fvp.alpha = alpha2) THEN 1

WHEN (c.fvp.gamma > beta2) AND

(c.fvp.alpha < alpha2)

THEN (c.fvp.gamma - beta2) /

( c.fvp.delta - delta2 )

ELSE (gamma2 - c.fvp.beta) /

( c.fvp.delta + delta2 );"

FROM

WHERE

Translation Customization

• The framework builds an abstract syntax tree(AST) once the query passed lexical and syntac-tical analysis.

• The AST represents tokens as nodes. The se-mantic analyzer renders the tree in the into SQLsentences. Then the dialect customizes the SQLsentence.

Page 34: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 34 of 37

Go Back

Full Screen

Close

Quit

Example:

ID Name Salary BossID FVP001 Josh 1200 C [10/10/2009,27/10/2009,19/10/2010,27/10/2010]001 Josh 1500 B [19/10/2010,27/10/2010,-,-]002 Robert 800 A [14/05/2007,25/05/2007,17/01/2008,30/01/2008]002 Robert 1200 A [17/01/2008,30/01/2008,24/05/2009 ,30/05/2009]002 Robert 1400 A [24/05/2009,30/05/2009,28/10/2010,30/10/2010]003 Alex 2100 - [02/05/2007,15/05/2007,-,-]004 Tyna 1300 002 [25/07/2009,30/7/2009,15/10/2009,25/10/2009]005 Rose 2300 003 [25/09/2010,30/09/2010,25/02/2011,30/02/2011]

”Find all the employees with the boss 002 during the same period oftime.”

SELECT e,f FROM Employee e, Employee f WHERE e.ID="002"

AND e.ID<>f.ID AND e.fvp EQUALS f.fvp;

e.ID e.name f.ID f.name Comp.001 Josh 004 Tyna 0, 55

Page 35: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 35 of 37

Go Back

Full Screen

Close

Quit

5. Conclusions and FutureWork

• We introduced a framework for the representa-tion of fuzzy types and for fuzzy querying.

• The implementation within Hibernate is basedon the portability.

• The drawback for the portability is the depen-dency between the application and the frame-work.

Page 36: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 36 of 37

Go Back

Full Screen

Close

Quit

Future work:

• Fuzzy querying: bipolar specification in thequeries

• Applications in historical databases: the time isusually not precisely known.

• New fuzzy temporal representation: representa-tion for Fuzzy Validity Periods and implementa-tion of temporal comparisons within the Allen’srelations.

Page 37: A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework

Contents

Motivation

Context

Proposal

Example

Comparison

Conclusions and . . .

Home Page

Title Page

JJ II

J I

Page 37 of 37

Go Back

Full Screen

Close

Quit

Thank you!

Questions?

Contact:

[email protected]