Generalised fuzzy types and querying.Implementation within the Hibernate Framework
-
Upload
jose-enrique-pons -
Category
Technology
-
view
139 -
download
0
description
Transcript of Generalised fuzzy types and querying.Implementation within the Hibernate Framework
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 1 of 26
Go Back
Full Screen
Close
Quit
Generalised fuzzy types andquerying.
Implementation within theHibernate Framework.
Jose Enrique Pons Olga Pons CapoteIgnacio Blanco Medina
Department of Computer Science and Artificial IntelligenceUniversity of Granada, Spain{jpons,opc,iblanco}@decsai.ugr.es
October 27, 2011
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 2 of 26
Go Back
Full Screen
Close
Quit
1. Contents
The structure of the presentation is:
• Motivation.
• Context:
– Fuzzy relational databases.
– Hibernate Framework.
• Proposal.
• Comparison.
• Conclusions and future work.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 3 of 26
Go Back
Full Screen
Close
Quit
2. Motivation
• A true standard for fuzzy databases does not ex-ist.
• Relational databases are usually the base for theimplementation of fuzzy databases.
• General model to represent and querying fuzzytypes in any relational database.
• Implementation within the Hibernate Frame-work.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 4 of 26
Go Back
Full Screen
Close
Quit
3. Context
• 3.1 Fuzzy relational databases (FBD):
– Representation: fuzzy data types.
– Querying: flexible querying.
• 3.2 Hibernate Framework:
– Architecture.
– Querying in the Hibernate Framework
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 5 of 26
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 restaurant.”
• Flexible querying:”The user wants to obtain a list with cheaprestaurants.”
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 6 of 26
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
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 7 of 26
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
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 8 of 26
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
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 9 of 26
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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 10 of 26
Go Back
Full Screen
Close
Quit
Context
• 3.1 Fuzzy relational databases (FBD):
– Representation: fuzzy data types.
– Querying: flexible querying.
• 3.2 Hibernate Framework:
– Architecture.
– Querying in the Hibernate Framework
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 11 of 26
Go Back
Full Screen
Close
Quit
3.2. 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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 12 of 26
Go Back
Full Screen
Close
Quit
3.2.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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 13 of 26
Go Back
Full Screen
Close
Quit
Hibernate Architecture:
HIBERNATE
XML mapping
Application
Persistent Objects
hibernate.
properties
Database
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 14 of 26
Go Back
Full Screen
Close
Quit
3.2.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 Person p where p.login =”lmmn”;
4. SQL:Select * from Person as p where p.login =’lmmn’;
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 15 of 26
Go Back
Full Screen
Close
Quit
4. Proposal
• Architecture for the general framework for:
– Fuzzy representation.
– Fuzzy querying.
• Implementation within the Hibernate frame-work.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 16 of 26
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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 17 of 26
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)
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 18 of 26
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
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 19 of 26
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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 20 of 26
Go Back
Full Screen
Close
Quit
Query translation:
Select
rfrom
whereRestaurant
r.priceAvg [15,10,20,5]
FEQ
• 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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 21 of 26
Go Back
Full Screen
Close
Quit
Example:The user wants restaurants that have an averageprice around 15 euro:
SELECT r FROM Restaurant r WHEREr.PriceAvg FEQ [15, 10, 20, 5];
The FEQ node is rendered to its implementation inSQL:
SELECT * FROM Restaurant as r WHERE
1 < CASE WHEN (r.priceAvg.gamma <= beta2)
OR (r.priceAvg.beta >= gamma2) THEN 0
WHEN (r.priceAvg.alpha = alpha2) THEN 1
WHEN (r.priceAvg.gamma > beta2) AND (r.priceAvg.alpha < alpha2)
THEN (r.priceAvg.gamma - beta2) / ( r.priceAvg.delta - delta2 )
ELSE (gamma2 - r.priceAvg.beta) / ( r.priceAvg.delta + delta2 );
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 22 of 26
Go Back
Full Screen
Close
Quit
5. Comparison
Portability among the proposals:
• FSQL server: The reference implementation of the FIRST inter-face on the GEFRED model. The first implementation works withOracle database, although there is an implementation in Post-greSQL.
• SQLfi: The implementation for the SQLf language.
• FDBLL: Fuzzy database language and library . A fuzzy SQLimplementation in C language over a relational DBMS.
• PSQL: An extension of the FSQL model. The main features arethe use of priority fuzzy logic and the portability.
• Hibernate FSQL: The proposed implementation.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 23 of 26
Go Back
Full Screen
Close
Quit
Comparison table:
Fuzzy DB Catalog Interface Query language Query ProcessorFSQL Inside DB. FSQL client FSQL Procedural.SQLfi Inside DB. Client app. SQLf Procedural.FDBLL Inside DB. Client app. Fuzzy SQL Procedural.PFSQL Inside DB. JDBC client PFSQL Procedural.H. FSQL Outside DB. Entity Classes Fuzzy HQL Declarative.
The main differences are:
• The meta data for the fuzzy types are not stored in the database, therefore,to change the running database is as easy as changing some parameters inthe Hibernate configuration file.
• There is no need to create or modify fuzzy meta tables in the DBMS catalog.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 24 of 26
Go Back
Full Screen
Close
Quit
6. Conclusions and FutureWork
• We introduced a general model for the represen-tation 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.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 25 of 26
Go Back
Full Screen
Close
Quit
Future work:
• Fuzzy querying: bipolar specification in thequeries
• Practical applications with the proposed frame-work.
• Fuzzy temporal representation: representationfor Fuzzy Validity Periods and implementationof temporal comparisons within the Allen’s rela-tions.
Contents
Motivation
Context
Proposal
Example
Comparison
Conclusions and . . .
Home Page
Title Page
JJ II
J I
Page 26 of 26
Go Back
Full Screen
Close
Quit
Thank you!
Questions?
Contact:
http://decsai.ugr.es/˜ jpons