an open source framework for fuzzy representation and querying in fuzzy databases

31
An Open Source Framework for Fuzzy Representation and Querying in Databases José Enrique Pons Frías Olga Pons Capote Ignacio Blanco Medina

Upload: jose-enrique-pons

Post on 19-Jun-2015

138 views

Category:

Documents


1 download

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

Page 1: An open source framework for fuzzy representation and querying in fuzzy databases

An Open Source Framework for

Fuzzy Representation and

Querying in Databases

José Enrique Pons Frías

Olga Pons Capote

Ignacio Blanco Medina

Page 2: An open source framework for fuzzy representation and querying in fuzzy databases

Contents

Fuzzy databases Hibernate Framework Applications Conclusions and future work

Page 3: An open source framework for fuzzy representation and querying in fuzzy databases

Fuzzy Databases

Page 4: An open source framework for fuzzy representation and querying in 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

Page 5: An open source framework for fuzzy representation and querying in 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

Page 6: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 7: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 8: An open source framework for fuzzy representation and querying in fuzzy databases

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:

Page 9: An open source framework for fuzzy representation and querying in fuzzy databases

Fuzzy Databases

Fuzzy operators: FEQ: Fuzzy Equals FGT: Fuzzy Greater than …

Necessity operators: NEQ: Necessity Equal...

FLEQ operator

Trapezoid poss. dist.

Page 10: An open source framework for fuzzy representation and querying in fuzzy databases

Hibernate Framework

Page 11: An open source framework for fuzzy representation and querying in fuzzy databases

Applications

Hibernate Framework Hibernate OR mapping. Querying in Hibernate. Fuzzy Data types in Hibernate Flexible querying in Hibernate Fuzzy temporal data types and operators.

Page 12: An open source framework for fuzzy representation and querying in fuzzy databases

Hibernate Framework

MySQL, Oracle, PosgreSQL, O2, HsqlDb, ...,

An Open Source Frameworkfor Object-relational mapping

Page 13: An open source framework for fuzzy representation and querying in fuzzy databases

Hibernate Framework Apps

www.facturae.es

PLAMSI

Mapache Server

Page 14: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 15: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 16: An open source framework for fuzzy representation and querying in fuzzy databases

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'”;

Page 17: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 18: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 19: An open source framework for fuzzy representation and querying in fuzzy databases

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 !

Page 20: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 21: An open source framework for fuzzy representation and querying in fuzzy databases

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:

Page 22: An open source framework for fuzzy representation and querying in fuzzy databases

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.

Page 23: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 24: An open source framework for fuzzy representation and querying in fuzzy databases

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)”

Page 25: An open source framework for fuzzy representation and querying in fuzzy databases

Applications

Page 26: An open source framework for fuzzy representation and querying in fuzzy databases

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'

Page 27: An open source framework for fuzzy representation and querying in fuzzy databases

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

Page 28: An open source framework for fuzzy representation and querying in fuzzy databases

Conclusions

Fuzzy querying and fuzzy representation is now possible in almost any relational database supported by the framework.

Page 29: An open source framework for fuzzy representation and querying in fuzzy databases

Future work

Representation of fuzzy temporal information.

Extension of the model for bipolar queries.

New applications with fuzzy temporal and bipolar information.

Page 30: An open source framework for fuzzy representation and querying in fuzzy databases

Thank you

+ Info: Hibernate: www.hibernate.org

Email: [email protected]

Page 31: An open source framework for fuzzy representation and querying in fuzzy databases