an open source framework for fuzzy representation and querying in fuzzy databases
DESCRIPTION
A fuzzy database has two main features: flexible querying and representation of imprecision or vagueness. The first feature allows querying in linguistic terms.(i.e. selections in terms of age labels like 'young' or 'middle-aged' customers). The representation of vagueness is done by means of possibility distributions and fuzzy constants like 'UNKNOWN' or 'UNDEFINED'. Some comparison operators are usually defined in order to get a similarity degree between fuzzy values. The current paper is based on the ability of an open source framework called Hibernate to isolate the applications from the database implementation. Thus, the present implementation of fuzzy types and flexible querying within Hibernate extends any relational database into a fuzzy database.TRANSCRIPT
An Open Source Framework for
Fuzzy Representation and
Querying in Databases
José Enrique Pons Frías
Olga Pons Capote
Ignacio Blanco Medina
Contents
Fuzzy databases Hibernate Framework Applications Conclusions and future work
Fuzzy Databases
Fuzzy Databases
Flexible querying select every people
which are in its thirties.
#ID Name Age Eye Color
Hair Color
1 Peter 24 Brown Blonde
2 Maria 34 Blue Blonde
3 John 52 Brown Brown
4 Sarah 29 Green Brown
Fuzzy Databases
Flexible querying select every people
which are in its thirties.
#ID Name Age Eye Color
Hair Color
1 Peter 24 Brown Blonde
2 Maria 34 Blue Blonde
3 John 52 Brown Brown
4 Sarah 29 Green Brown
Fuzzy Databases
Fuzzy Datatypes Fuzzy datatypes in an
ordered underlying domain.
#ID Name Age Eye Color
Hair Color
1 Peter Brown Blonde
2 Maria 'Young' Blue Blonde
3 John UNKNOWN
Brown Brown
4 Sarah 29 Green Brown
Fuzzy Databases
Fuzzy Datatypes Fuzzy data types in an
underlying non-ordered domain
#ID Name Age Eye Color
Hair Color
1 Peter 24 Brown Blonde
2 Maria 34 Blue Blonde
3 John 52 Brown Brown
4 Sarah 29 Green Brown
Fuzzy Databases
Fuzzy Datatypes Fuzzy data types in an
underlying non-ordered domain
#ID Name Age Eye Color
Hair Color
1 Peter 24 Brown Blonde
2 Maria 34 Blue Blonde
3 John 52 Brown Brown
4 Sarah 29 Green Brown
Brown Blue Green
Brown 1 0.1 0.1
Blue 1 0.6
Green 1
Fuzzy compatibility degrees:
Fuzzy Databases
Fuzzy operators: FEQ: Fuzzy Equals FGT: Fuzzy Greater than …
Necessity operators: NEQ: Necessity Equal...
FLEQ operator
Trapezoid poss. dist.
Hibernate Framework
Applications
Hibernate Framework Hibernate OR mapping. Querying in Hibernate. Fuzzy Data types in Hibernate Flexible querying in Hibernate Fuzzy temporal data types and operators.
Hibernate Framework
MySQL, Oracle, PosgreSQL, O2, HsqlDb, ...,
An Open Source Frameworkfor Object-relational mapping
Hibernate Framework Apps
www.facturae.es
PLAMSI
Mapache Server
Hibernate O-R-Mapping
Person{
Name
SurName
Age
Gender
…
Login
Password
}
==
=
=
=
=
Rs[0];Rs[1];
Rs[2];
Rs[3];
…
Rs[N-1];
Rs[N];
Without Hibernate, after a query, the resultset must be fitted field by field in the object
Hibernate O-R-Mapping
Person{
Name
SurName
Age
Gender
…
Login
Password
}
==
=
=
=
=
Rs[0];Rs[1];
Rs[2];
Rs[3];
…
Rs[N-1];
Rs[N];
Without Hibernate, after a query, the resulset must be fitted field by field in the object
Querying in Hibernate Framework
Query by criteria: A more complex selection method. Selects objects that fulfill a set of criteria.
Query by example: Selects objects similar to a given object.
HQL: Hibernate Query Language: An object oriented query language.
SQL: An SQL sentence.
createCriteria(Person.class).Add(Restrictions.eq(“login”, ”jpons”));
Person p;p.login = “jpons”;
“Select p from Person pWhere p.login = 'jpons'”;
“Select * from Person p where p.login = 'jpons'”;
Querying in Hibernate Framework
Query by criteria: A more complex selection method. Selects objects that fulfill a set of criteria.
Query by example: Selects objects similar to a given object.
HQL: Hibernate Query Language: An object oriented query language.
SQL: An SQL sentence.
createCriteria(Person.class).Add(Restrictions.eq(“login”, ”jpons”));
Person p;p.login = “jpons”;
“Select p from Person pWhere p.login = 'jpons'”;
“Select * from Person p where p.login = 'jpons'”;
Each query is translated into a SQL sentence
Query translationHQL sentence: “Select p from Personal where p.login like 'lmmn';
SQL sentence: “Select * from Personal as p where p.login like 'lmmn';
AST: Abstract Sintax Tree
Select
p from
Personal whereThrough the dialect
Fuzzy datatypes in Hibernate
Allows definition of new fuzzy domains:
Fuzzy Domains in underlying ordered domain.
Fuzzy Domains in underlying non-ordered domain.
Any relational database supported by Hibernate, allows fuzzy data types now !
Fuzzy datatypes in Hibernate
Fuzzy Datatypes Fuzzy datatypes in an
ordered underlying domain.
#ID Name Age Eye Color
Hair Color
1 Peter Brown Blonde
2 Maria 34 Blue Blonde
3 John 52 Brown Brown
4 Sarah 29 Green Brown
Fuzzy Databases in Hibernate
Fuzzy Datatypes Fuzzy data types in an
underlying non-ordered domain
#ID Name Age Eye Color
Hair Color
1 Peter 24 Brown Blonde
2 Maria 34 Blue Blonde
3 John 52 Brown Brown
4 Sarah 29 Green Brown
Brown Blue Green
Brown 1 0.1 0.1
Blue 1 0.6
Green 1
Fuzzy compatibility degrees:
Fuzzy querying in Hibernate
Two conditions met:
Declarative implementation of Fuzzy operators in SQL.
The AST is modified when a fuzzy operator is applied to a fuzzy type.
Declarative implementationCASE WHEN 1≤2 ∨1≥2 THEN 0
CASE WHEN 1=2 THEN 1
CASE WHEN 12∧12 THEN round 1−21−2
ELSE round 2−112
AST modification
p.age
FEQ
'young'
where
HQL: “Select p From Personal where p.age FEQ 'young';”
...
In the translation process from AST to SQL, the FEQ node is modified..
Select * From Personal as p where 1 < CASE WHEN (p.age.alfa<= beta2) OR (p.age.beta >=alfa2) THEN 0WHEN (p.age.alfa = alfa2) THEN 1WHEN (p.age.beta > beta2) AND (p.age.alfa < alfa2)
THEN round( (p.age.alfa – beta2) / (p.age.delta – delta2),2)ELSE round ( (alfa2 – p.age.beta) / (p.age.delta + delta2)”
Applications
Selection of target customers
#ID Name Surname Age Average Balance
1 Peter Parker 26 1500€
2 Ann Green 30 1100€
3 Laurie Doe 19 600€
Customers table
#ID Service Name
Target Age
1 Rechargeable credit card
'Young'
2 Low rate mortgage
'Middle-Age'
Table with services and fuzzy attribute 'target age'
Selection of target customers
Obtaining the most interesting customer for each service:
SELECT s,c FROM Customers c, Services s WHERE c.age FEQ s.targetAge
s.#ID s.Service Name
s.Target Age c.#ID c.Name ... Age Compatibility
1 Rechargeable credit card
'Young' 1 Peter ... 26 0.1
1 Rechargeable credit card
'Young' 3 Laurie ... 19 1
2 Low rate mortgage
'Middle-Age' 1 Peter ... 26 0.9
2 Low rate mortgage
'Middle-Age' 2 Ann ... 30 1
Conclusions
Fuzzy querying and fuzzy representation is now possible in almost any relational database supported by the framework.
Future work
Representation of fuzzy temporal information.
Extension of the model for bipolar queries.
New applications with fuzzy temporal and bipolar information.