Download FuzzySQL

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Fuzzy SQL
Atsez Eawaz
Fuzzy Systems Course
June, 2005
SQL – Structured Query Language

Presented in 1974
Standardized in 1986 by ANSI and ISO

DML – Data Manipulation Language



SELECT, INSERT, DELETE …
DDL – Data Definition Language

CREATE, DROP, ALTER
2
SELECT * FROM STUDENTS
WHERE (GPA >= 3.5) AND (ABSENCES < 10)
Name
GPA
Absences
Becky Springston
4.0
3.0
Jeff Williams
3.5
9.75
Leroy Jefferson
3.75
4.5
Mike Salisbury
4.0
1.0
Kevin Costner
3.75
1.0
Shelly Whitman
3.75
4.0
Barry Allen
3.9
2.0
Billy Kidd
4.0
9.75
John Conner
4.0
7.0
3
SELECT * FROM STUDENTS
WHERE (GPA >= 3.5) AND (ABSENCES < 10)
ORDER BY GPA DESC, ABSENCES ASC ;
Name
GPA
Absences
Mike Salisbury
4.0
1.0
Becky Springston
4.0
3.0
John Conner
4.0
7.0
Billy Kidd
4.0
9.75
Barry Allen
3.9
2.0
Kevin Costner
3.75
1.0
Shelly Whitman
3.75
4.0
Leroy Jefferson
3.75
4.5
Jeff Williams
3.5
9.75
4
5
6
(GPA is GOOD) AND (ABSENCES is GOOD)
7
Reviewing 2 System
1. Linux operating system
target DBMS  Postgress
2. Written by C
on OMRON LUNA88K workstation
Fuzzy Comparators :

Possibility Comparators


Necessity Comparators


F=, F!=, F>, F>=, F<, F<=, F>>, F<<
NF=, NF!=, NF>, NF>=, NF<, NF<=, NF>>, NF<<
Inclusion

FINCL, INCL
9
Fuzzy Constants
10
Fulfillment threshold
<condition> THOLD τ
Condition must be satisfied with minimum degree
τ to be considered.
  0,1
11
Function CDEG()

CDEG (attribute)



If attribute is in condition  fulfillment of
attribute in condition
Otherwise  1
CDEG (*)

Fulfillment degree of each tuple (with all of its
attributes)
12
SELECT statement
SELECT A [,CDEG(*)]
FROM R [, <table-clause>]
WHERE [ONCEPERGROUP]
&FQuantifier THOLD τ
(<sub query>)
13
Fuzzy Set Operators

FUNION (s-norm)



FINTERSECT (t-norm)



All rows selected by either query.
If duplicated, use max CDEG
All rows selected by both queries.
If duplicated, use min CDEG
FMINUS (s-norm)


All distinct rows selected by first but not second
If duplicated, use max CDEG
14
Fuzzification
15
Some Examples
SELECT * FROM Players
WHERE Quality F= $Good AND
FDEGREE(Quality) > 0.5;
SELECT Owner.Name, Pet.FDEGROW
FROM Pet, Owner
WHERE Pet.Owner_ID = Owner.Owner_ID
AND Pet.FDEGROW > $ Very_High
16
17
FDL2 – Fuzzy Database Library



Relational database consist of one or more
relation
Each relation consist of one or more
attributes
Relation R characterized by :
μR : D1 X D2 X … X Dn  [0,1]

GRADE: membership value, added to a
relation.
18
Example of Relation young people
19
Fuzzy Data - 1

Reliability Degree Value


Reliability degree of each stored data for each
attribute in a relation
This has [0,1] continuous values.
20
Fuzzy Data - 2

Fuzzy Number


Represents fuzziness of numerical data like
“about 20”
Membership function
( x N 1  x)
0
( x  x ) /( x  x ) ( x  x  x )

N1
N2
N1
N1
N2
 FN ( x)  
( xN 3  x) /( xN 3  xN 2 ) ( xN 2  x  xN 3 )
0
( x N 3  x)
21
Fuzzy Data - 3

FIXED method

RATED method
 xN 1  xN 2  w

 xN 3  xN 2  w
 xN 1  xN 2  xN 2  p  w

 xN 3  xN 2  xN 2  p  w
22
Fuzzy Data - 4

Fuzzy Label


Represents fuzziness of numerical data like
“young”
Membership function
0
( x  x ) /( x  x )
L1
L2
L1

 FL ( x)  1
( x  x) /( x  x )
L4
L3
 L4
0
( xL1  x)
( xL1  x  xL 2 )
( xL 2  x  xL 3 )
( xL 3  x  xL 4 )
( xL 4  x)
23
Fuzzy Data - 5

String Fuzzy Set


Represents fuzziness of string data like “likered”
Fuzzy set definition
n
~
A    A~ ( xi ) / xi
i 1
24
Column Definition


Column that store fuzzy data should be
explicitly specified.
Can use column constraint



FUZZY
CHECK
WITH
25
Example
CREATE TABLE People
( Name
CHAR(8)
Age
DEC(3)
Hair_Color
Hobby
Height
Weight
CHAR(12)
CHAR(12),
DEC(3)
Dec(3)
NOT NULL,
FUZZY RELDEG
CHECK Age >= young
WITH GRADE > 0,
FUZZY,
FUZZY,
FUZZY)
26
Fuzzy Data Definition - 1

Fuzzy Number


Defined by: CREATE FUZNUM
3 parameters
RATED – FIXED
 Width specification value
 Width constant value


e.g. CREATE FUZNUM (RATED, 10, 2.0)
27
Fuzzy Data Definition - 2

Fuzzy Labels

Defined by: CREATE FUZLAB
4 parameters: trapezoidal coordinates

e.g. CREATE FUZLAB (young (0, 0, 20, 30)

28
Fuzzy Data Definition - 3

String Fuzzy Sets


Defined by: CREATE STRFSET
parameters
names of string fuzzy sets
 pair of elements and corresponding membership
value


e.g. CREATE STRFSET
(like-red (‘red’ 1.0, ‘pink’ 0.7))
29
Fuzzy Data Definition - 4

Linguistic modifier


Defined by: CREATE HEDGE
Parameters
modifier name
 shifting method type
 shifting volume


e.g. CREATE HEDGE
(very TIGHT 1, more_or_less WIDE 1)
30
Fuzzy Data Definition - 5

Fuzzy Relation


Defined by: CREATE FUZREL
e.g. CREATE FUZREL
(hobby_similarity
(‘Dancing’ ‘Sports’ 0.8))
31
CREATE FDD young_people.age
CREATE FUZNUM (RATED, 10, 2.0)
CREATE FUZLAB (
(young NMF (0, 0, 20, 30),
old
NMF (40, 50, 150, 150))
CREATE HEDGE (very TIGHT 1, more_or_less WIDE 1)
CREATE FDD young_people.hair_color
CREATE STRFSET (
like_red (‘red’ 1.0, ‘pink’ 0.7, ‘orange’ 0.3))
CREATE FDD young_people.hobby
CREATE FUZREL (hobby_similarity (‘Dancing’ ‘Sport’ 0.8)
(‘Dancing’ ‘Singing’ 0.7))
32
Data Manipulation - 1

Predicate



Linguistic Modifiers


result in grade [0,1]
=,<>,<,>,<=,>=,~=,<<,>>,BETWEEN,IN,LIKE,
ANY,SOME,ALL,EXISTS
Change the shape of membership function
Arithmetic Operator
33
Data Manipulation - 2

Aggregate Functions


Relational Operators



COUNT, AVG, SUM, MIN, MAX
Calculate GRADE column value
in UNION, max value is calculated
Limitation Conditions



Using WITH keyword
Quantity limitation
Quality limitation
34
‘Find young people and the GRADE is greater than 0.5
SELECT Name, Age, Hair_color, hobby
FROM People
WHERE age = young
WITH GRADE > 0.5
‘Find 20 people who are much taller than 170cm and have like red hair color
SELECT name, height, weight
FROM People
WHERE (height >> 170) AND (Hair_color = like_red)
WITH LINES = 20
‘Find the people who are age is young (0.6) and income is high (1.0)
‘REL : Reliability degree value
‘0.6 and 1.0 : Importance degree value of each argument of mean operator
SELECT name, age, income
FROM People
WHERE MEAN ( (age = young, REL(age) * 0.6) ,
(income >= high, REL(income) * 1.0)
35
Architecture of Fuzzy Database using FDL2
36
References
1. A.Urrutia, L.Pavesi, “Extending the capabilities of database
queries using fuzzy logic”, University of Maule, 2004.
2. H.Nakajima, et al, “Fuzzy database language and library”,
FUZZ-IEEE’93, pp. 477-482.
3. P.Bosc, et al, “SQLf: A relational database language for fuzzy
querying”, 1995, IEEE Trans on Fuzzy Systems, 3, pp. 1-17.
4. P.Bosc, et al, “Fuzzy querying with SQL: extension and
implementation aspects”, 1998, Fuzzy Set and Systems, 28,
pp. 333-349.
5. http://fuzzy.sonalysts.com
37
Thanks for your patient
Any question ?
38
Related documents