Time in databases has been studied for a long time. Valid time databases capture when the objects are true in the reality. The proposed model allows both representing and querying time in a fuzzy way. The representation and the underlying domain are defined as well as some fuzzy temporal operators. The implementation of the model is developed within the Hibernate framework. The Hibernate framework acts as an abstraction for the running database. Therefore, any relational database supported by the framework can now represent fuzzy valid time in its schema.
Amazon CloudFront - Delivering Dynamic Content From The Edge
A Fuzzy Valid-Time Model for Relational Databases Within the Hibernate Framework
1. A Fuzzy Valid-Time Model Contents
Motivation
for Relational Databases Context
Proposal
Example
Within the Hibernate Comparison
Conclusions and . . .
Framework Home Page
Title Page
Jos´ Enrique Pons
e Olga Pons Capote
Ignacio Blanco Medina
Department of Computer Science and Artificial Intelligence
University of Granada, Spain
{jpons,opc,iblanco}@decsai.ugr.es Page 1 of 37
October 22, 2011 Go Back
Full Screen
Close
Quit
2. 1. Contents Contents
Motivation
Context
The structure of the presentation is: Proposal
Example
• Motivation. Comparison
Conclusions and . . .
• Context: Home Page
– Fuzzy relational databases. Title Page
– Temporal databases.
– Fuzzy temporal databases.
– Hibernate. Page 2 of 37
• Proposal: Fuzzy Valid-Time model for relational Go Back
databases. Full Screen
• Conclusions and future work. Close
Quit
3. Contents
Motivation
2. Motivation Context
Proposal
Example
• Time-related attributes are considered to have Comparison
Conclusions and . . .
an impact on the consistency of the object set Home Page
modelled by the database.
Title Page
• A true standard for fuzzy temporal databases
does not exist.
• General model to represent and querying fuzzy Page 3 of 37
temporal types in any relational database.
Go Back
• Portable implementation within the Hibernate Full Screen
Framework.
Close
Quit
4. 3. Context Contents
Motivation
Context
• 3.1 Fuzzy relational databases (FBD): Proposal
Example
– Representation: fuzzy data types. Comparison
Conclusions and . . .
– Querying: flexible querying. Home Page
• 3.2 Temporal databases: Title Page
– Time models (valid-time, transaction time,
decision time... )
– Temporal operators. Page 4 of 37
• 3.3 Fuzzy temporal databases: Go Back
– Fuzzy Validity Period. Full Screen
• Hibernate. Close
Quit
5. Contents
3.1. Fuzzy relational databases Motivation
Context
Proposal
Two main features: Example
Comparison
• Fuzzy representation Conclusions and . . .
”The restaurant X in the database is cheap in Home Page
average.” Title Page
”The restaurant X in the database is a ham-
burguer bar.”
• Flexible querying: Page 5 of 37
”The user wants to obtain a list with cheap
restaurants.” Go Back
Full Screen
Close
Quit
6. 3.1.1. Fuzzy data types
Two main types:
Contents
• Ordered underlying domain: Motivation
possibility
Context
Cheap Middle-price Expensive
1 Proposal
Example
Comparison
Conclusions and . . .
Home Page
Price
0
16 18 24 26
Title Page
This data type may be represented as a trapezoid
in the form: [α, β, γ, δ].
E.g. Middle-price = [16, 18, 24, 26]
Page 6 of 37
• Non-ordered underlying domain:
Fast food Hamburger Chinese Go Back
Fast food 1 0.8 0.6 Full Screen
Hamburger 0.8 1 0.2 Close
Chinese 0.6 0.2 1 Quit
7. 3.1.2. Flexible Querying
The user may query with vagueness in the database: Contents
”The user want to obtain a list of cheap restau- Motivation
Context
rants.” Proposal
Example
ID Name AVG Quality Comparison
Conclusions and . . .
001 Amadeus [15,10,20,5] 5 Home Page
002 Atlantis [11,5,17,6] 3 Title Page
003 Cafe Theatre [20,10,30,10] 2
004 De Graslei [23,18,28,5] 5
005 Pakhuis [13,11,15,2] 3
006 De 3 Biggetjes [45,25,65,20] 4 Page 7 of 37
possibility
Cheap Middle-price Expensive
1
Go Back
Full Screen
Price Close
0
16 18 24 26
Quit
8. Contents
Motivation
Context
Proposal
Example
The selected restaurants are: Comparison
Conclusions and . . .
Home Page
ID Name AVG Quality
001 Amadeus [15,10,20,5] 5 Title Page
002 Atlantis [11,5,17,6] 3
005 Pakhuis [13,11,15,2] 3
Page 8 of 37
Go Back
Full Screen
Close
Quit
9. Operators for fuzzy querying:
Contents
Possibility Necessity Possibly / Necessarily Motivation
FEQ NFEQ Fuzzy = Context
Proposal
FGT NFGT Fuzzy > Example
FGEQ NFGEQ Fuzzy ≥ Comparison
Conclusions and . . .
FLT NFLT Fuzzy.< Home Page
FLEQ NFLEQ Fuzzy ≤
Title Page
MGT NMGT Much >
MLT NMLT Much <
F EQ(p1, p2) = sup min(πp1(d), πp2(d)) (1)
d∈U Page 9 of 37
Where U is the underlying domain, p1, p2 are two Go Back
values of a given fuzzy type (e.g. fuzzy type 2) and Full Screen
πp1(d), πp2(d) are the associated possibility distribu- Close
tions.
Quit
10. Context:
Contents
Motivation
Context
• 3.1 Fuzzy relational databases (FBD): Proposal
Example
– Representation: fuzzy data types. Comparison
Conclusions and . . .
– Querying: flexible querying. Home Page
• 3.2 Temporal databases: Title Page
– Time models (valid-time, transaction time,
decision time... )
– Temporal operators. Page 10 of 37
• 3.3 Fuzzy temporal databases: Go Back
– Fuzzy Validity Period. Full Screen
Close
Quit
11. Contents
Motivation
Context
Proposal
Example
3.2. Temporal Databases: Comparison
Conclusions and . . .
Home Page
A temporal database is a database that manages the
time in its schema. Title Page
Time-related attributes have an impact on the con-
sistency of the database.
Page 11 of 37
Go Back
Full Screen
Close
Quit
12. Contents
Motivation
Context
Example: Proposal
Example
Comparison
ID Name Year Works for Start Year End Year
Conclusions and . . .
1 Peter 1987 John 2010 -
Home Page
2 Maria 1978 John 2001 -
3 John 1954 - 1999 - Title Page
4 Sarah 1982 Maria 2005 2009
Consider that ID is the primary key.
Problem: If Sarah is hired in 2010, we can not
insert the new tuple. Page 12 of 37
Go Back
Full Screen
Close
Quit
13. Contents
Example: Motivation
Context
Proposal
New primary key: Example
Comparison
Conclusions and . . .
{ ID ∪[ Start Year, End Year ]} Home Page
Title Page
ID Name Year Works for Start Year End Year
1 Peter 1987 John 2010 -
2 Maria 1978 John 2001 -
3 John 1954 - 1999 -
4 Sarah 1982 Maria 2005 2009
Page 13 of 37
4 Sarah 29 Maria 2010 -
Go Back
Also a consistence mechanism must be defined...
Full Screen
Close
Quit
14. Contents
Example: Motivation
Context
Proposal
Some spurious values might be inserted: Example
Comparison
Conclusions and . . .
ID Name Year Works for Start Year End Year
Home Page
1 Peter 1987 John 2010 -
2 Maria 1978 John 2001 - Title Page
3 John 1954 - 1999 -
4 Sarah 1982 Maria 2005 2009
4 Sarah 29 Maria 2001 2007
4 Sarah 1982 Maria 2010 -
Page 14 of 37
Usually, DML sentences (insert, update, delete) are
re-defined to ensure consistency. Go Back
Full Screen
Close
Quit
15. Contents
3.2.1. Temporal models Motivation
Context
• Valid-Time: The time when the fact is true in Proposal
Example
the modelled reality. Comparison
Conclusions and . . .
• Transaction time: The time when the fact is Home Page
stored in the database.
Title Page
• Decision-time: The time when an event was
decided to happen.
• Bi-temporal: Valid and transaction time. Page 15 of 37
• Tri-temporal: Valid, transaction and decision Go Back
time. Full Screen
Close
Quit
16. Contents
Motivation
Context
3.2.2. Temporal operators: Proposal
Example
Allen’s temporal relation between intervals: Comparison
Conclusions and . . .
Operator Inverse Representation
Home Page
X Before Y After XXX YYY
XXX
X Equal Y Equal YYY Title Page
X Meets Y Meet by XXXYYY
XXX
X Overlaps Y Overlap by YYY
XXX
X During Y Contains YYYYYY
XXX
X Starts Y Start by YYYYYY
XXX Page 16 of 37
X Finishes Y Finished by YYYYYY
Go Back
Full Screen
Close
Quit
17. Context:
Contents
Motivation
• 3.1 Fuzzy relational databases (FBD): Context
Proposal
– Representation: fuzzy data types. Example
Comparison
– Querying: flexible querying. Conclusions and . . .
Home Page
• 3.2 Temporal databases:
Title Page
– Time models (valid-time, transaction time,
decision time... )
– Temporal operators.
Page 17 of 37
• 3.3 Fuzzy temporal databases: Go Back
– Fuzzy Validity Period. Full Screen
– Fuzzy temporal operators. Close
Quit
18. Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
3.3. Fuzzy temporal databases: Title Page
Page 18 of 37
Go Back
Full Screen
Close
Quit
19. 3.3.1. Fuzzy Validity Period:
possibility VET Contents
VST
Initial data values
1 Motivation
Context
Proposal
S1 Example
0 time Comparison
ds-as ds ds+bs de-ae de de+be
Conclusions and . . .
possibility Home Page
1
Title Page
S2
time
0
α=d1-a β= d1 γ= d2 δ= d2+b
(ds + bs ) − (ds − as ) d1 − (d1 − a) Page 19 of 37
S1 = S2 ⇒ = (2)
2 2
Go Back
Where d1 = ds + bs and d2 = de + ae. Full Screen
The FVP is [d1 − a, d1, d2, d2 + b]. Close
Quit
20. Contents
Motivation
Context
Proposal
Example
Underlying domain: Julian Day Number (JDN): A Comparison
counter which value is incremented in one unit every Conclusions and . . .
day since 1 January 4713 B.C noon. Home Page
Reasons: Title Page
• Representation as unique number
• Simplification of calculations.
Page 20 of 37
Go Back
Full Screen
Close
Quit
21. 3.3.2. Fuzzy temporal operators:
• BEFORE (I,J) =
Contents
1, if Iβ ≤ Jα
Motivation
Iα −Jβ
(Jα −Jβ )−(Iβ −Iα )
, if
Iβ > Jα and Iα < Jβ Context
0, otherwise (Iα ≥ Jβ ) Proposal
Example
Comparison
• OVERLAPS (I, J) = Conclusions and . . .
Home Page
sup (min (I (t) , J (t)))
t
Title Page
• CONTAINS (I, J) =
inf {max (1 − I (t) , J (t))}
t
Page 21 of 37
• EQUALS (I, J) = Go Back
min (CON T AIN S (I, J) , CON T AIN S (J, I)) = Full Screen
min(inf {max (1 − I (t) , J (t))},
t Close
inf {max (1 − J (t) , I (t))})
t
Quit
22. Contents
Motivation
Context
Proposal
Fuzzy temporal operators implemented in FSQL: Example
Comparison
Conclusions and . . .
Operator Name FSQL implementation Home Page
BEFORE (I, J) I FGEQ J Title Page
OVERLAPS (I, J) I FEQ J
EQUALS (I, J) min(I NFEQ J, J NFEQ I)
CONTAINS (I, J) I NFEQ J
Page 22 of 37
Go Back
Full Screen
Close
Quit
23. Contents
Motivation
Context
3.4. Hibernate Framework Proposal
Example
The Hibernate Framework is a collection of open Comparison
Conclusions and . . .
source projects that enable developers to make Home Page
object-relational mapping. Features: Title Page
• Database independent by means of dialects.
• HQL: an object-oriented query language.
• Open source. Page 23 of 37
Go Back
Full Screen
Close
Quit
24. 3.4.1. Architecture Contents
Motivation
An application working with Hibernate has 3 layers: Context
Proposal
1. Application layer: CRUD (CReate,Update Example
Comparison
and Delete) operations: Conclusions and . . .
(a) Persistent Objects: A current database state. Home Page
(b) Transient Objects: These objects do not rep- Title Page
resent a current database state.
2. Hibernate layer: An abstraction layer be-
tween the DBMS and the application. Page 24 of 37
3. The database: The running DBMS: MySQL, Go Back
PostgreSQL, Oracle...etc. Full Screen
Close
Quit
25. Contents
Motivation
Context
Proposal
Hibernate Architecture: Example
Comparison
Conclusions and . . .
Application
Home Page
Persistent Objects
HIBERNATE Title Page
hibernate. XML mapping
properties
Database
Page 25 of 37
Go Back
Full Screen
Close
Quit
26. 3.4.2. Querying in Hibernate
1. Query by criteria: Contents
createCriteria(Person.class). Motivation
Add(Restrictions.eq(”login”,”lmmn”)); Context
Proposal
Example
Comparison
2. Query by example: Conclusions and . . .
Person p.login = ”lmmn”; Home Page
Title Page
3. HQL:
Select p from Personal p where p.login =
”lmmn”; Page 26 of 37
Go Back
4. SQL: Full Screen
Select * from Person as p where p.login = Close
’lmmn’;
Quit
27. Contents
Motivation
Context
Proposal
Example
Comparison
4. Proposal Conclusions and . . .
Home Page
• Architecture for the general framework for: Title Page
– Fuzzy representation.
– Fuzzy querying.
Page 27 of 37
• Implementation within the Hibernate frame-
Go Back
work.
Full Screen
Close
Quit
28. Contents
Motivation
Context
4.1. Fuzzy Representation Proposal
Example
Conditions for portability: Comparison
Conclusions and . . .
1. The SQL standard is the interface. Home Page
Title Page
2. The fuzzy types are represented in the database
by basic SQL types.
3. The meta-data for managing properly the ex-
tended types relies outside the database catalog. Page 28 of 37
Go Back
Full Screen
Close
Quit
29. Contents
4.1.1. Architecture for the general model Motivation
Context
The architecture for a generalized object-oriented Proposal
Example
model needs the following elements: Comparison
Conclusions and . . .
Object-Oriented Layer.
O1 ON (OORL) Home Page
Object-Oriented to Relational. Title Page
(OO2RL).
RN Relational Layer.
R1
(RRL)
Conversion Layer. (CL)
Page 29 of 37
Go Back
MySQL PostgreSQL Oracle
Full Screen
Close
Quit
30. Contents
Motivation
4.1.2. Implementation Context
Proposal
The model has the following layers: Example
Comparison
Conclusions and . . .
Application
Home Page
Fuzzy Data Types Fuzzy Domains Fuzzy Representation
Constraint
Values Labels Constraint Layer (OORL) F Title Page
Validator
S
Fuzzy Data Fuzzy Domain Q
Types Adaptor Adaptor Adaptation L
Layer (OO2RRL)
Type 2 Type 3 & (RRL)
Hibernate Core
Conversion
Page 30 of 37
Layer (CL)
Database
Go Back
Full Screen
Close
Quit
31. Architecture with the FVP support: Contents
Motivation
Context
Proposal
Application
Example
Comparison
Hibernate FVP
Conclusions and . . .
Hibernate FSQL Home Page
Hibernate Title Page
Database
The Hibernate FSQL allows the representation and
querying of objects with fuzzy attributes. Page 31 of 37
The Hibernate FVP layer allows the use of Fuzzy Go Back
Validity Periods. Full Screen
Close
Quit
32. 4.2. Fuzzy Querying
The model uses the following elements:
Contents
• Declarative implementation for each fuzzy Motivation
Context
operator. This implementation should be done Proposal
in the SQL language. Example
Comparison
• Abstract syntax tree (AST) representa- Conclusions and . . .
Home Page
tion for the query. These representation allows
a customization process done by the conversion Title Page
layer (CL).
• Conversion Layer: This layer customizes the
AST for the running database. Page 32 of 37
The implementation of the fuzzy querying is done by Go Back
modifying the HQL language. The fuzzy operators Full Screen
are implemented in a declarative way in the SQL Close
language. Quit
33. Query translation:
Contents
SQL sentence
SELECT Motivation
"SELECT *
HQL sentence:
c,c1
FROM Customer as c, Context
"SELECT c
Translation FROM Customization Customer as c1
FROM Customer c, WHERE 1 < CASE WHEN Proposal
Customer c1 (c.fvp.gamma <= beta2)
WHERE c.fvp Customer WHERE OR (c.fvp.beta >= gamma2) THEN 0 Example
contains c1.fvp" WHEN (c.fvp.alpha = alpha2) THEN 1
WHEN (c.fvp.gamma > beta2) AND
Comparison
contains (c.fvp.alpha < alpha2)
THEN (c.fvp.gamma - beta2) /
( c.fvp.delta - delta2 )
Conclusions and . . .
c.fvp c1.fvp
ELSE (gamma2 - c.fvp.beta) /
( c.fvp.delta + delta2 );" Home Page
• The framework builds an abstract syntax tree Title Page
(AST) once the query passed lexical and syntac-
tical analysis.
• The AST represents tokens as nodes. The se- Page 33 of 37
mantic analyzer renders the tree in the into SQL Go Back
sentences. Then the dialect customizes the SQL Full Screen
sentence.
Close
Quit
34. Example:
Contents
ID Name Salary BossID FVP Motivation
001 Josh 1200 C [10/10/2009,27/10/2009,19/10/2010,27/10/2010] Context
001 Josh 1500 B [19/10/2010,27/10/2010,-,-]
Proposal
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] Example
002 Robert 1400 A [24/05/2009,30/05/2009,28/10/2010,30/10/2010] Comparison
003 Alex 2100 - [02/05/2007,15/05/2007,-,-] Conclusions and . . .
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] Home Page
”Find all the employees with the boss 002 during the same period of Title Page
time.”
SELECT e,f FROM Employee e, Employee f WHERE e.ID="002"
AND e.ID<>f.ID AND e.fvp EQUALS f.fvp; Page 34 of 37
Go Back
e.ID e.name f.ID f.name Comp. Full Screen
001 Josh 004 Tyna 0, 55
Close
Quit
35. Contents
Motivation
Context
5. Conclusions and Future Proposal
Example
Work Comparison
Conclusions and . . .
Home Page
• We introduced a framework for the representa- Title Page
tion of fuzzy types and for fuzzy querying.
• The implementation within Hibernate is based
on the portability.
Page 35 of 37
• The drawback for the portability is the depen- Go Back
dency between the application and the frame-
Full Screen
work.
Close
Quit
36. Contents
Motivation
Future work: Context
Proposal
• Fuzzy querying: bipolar specification in the Example
Comparison
queries Conclusions and . . .
• Applications in historical databases: the time is Home Page
usually not precisely known. Title Page
• New fuzzy temporal representation: representa-
tion for Fuzzy Validity Periods and implementa-
tion of temporal comparisons within the Allen’s Page 36 of 37
relations. Go Back
Full Screen
Close
Quit
37. Contents
Motivation
Context
Proposal
Example
Thank you! Comparison
Conclusions and . . .
Home Page
Questions?
Title Page
Contact:
jpons@decsai.ugr.es
Page 37 of 37
Go Back
Full Screen
Close
Quit