A new weighted fuzzy grammar on object oriented database queries

Article history: Received October 1, 2011 Received in Revised form November, 14, 2011 Accepted 25 February 2012 Available online 8 March 2012 The fuzzy object oriented database model is often used to handle the existing imprecise and complicated objects for many real-world applications. The main focus of this paper is on fuzzy queries and tries to analyze a complicated and complex query to get more meaningful and closer responses. The method permits the user to provide the possibility of allocating the weight to various parts of the query, which makes it easier to follow better goals and return the target objects. © 2012 Growing Science Ltd. All rights reserved.


Introduction
The Entrance of object orienting concept in databases caused the relation database gradually to replace with object oriented database in various fields.Since object oriented database has not been able to support existing non-definite data for the real-world applications, fuzzy concepts have recently been also added to these databases to let us have a kind of contact with a set of fuzzy objects through object oriented fuzzy databases (Ma et al., 2004).
Ma (Ma, 2005;Ma, 2006) defined the classes in a fuzzy way and created the fuzzy class to save the non-definite data in the object oriented databases.On the other side, Haroonabadi and Teshnelab (Haroonabadi, & Teshnelab, 2008;Haroonabadi & Teshnelab, 2009) laid out fuzzy-UML to model the existing non-definite (uncertainly) in the information systems.They also designed various relations graphs among the classes for fuzzy object oriented database but none of them mentioned anything about SQL grammar.
In this article, we propose a fuzzy grammar in SQL to increase the accuracy in fuzzy queries.Through applying this approach, a complicated fuzzy query can be handled easily and objects near to the user's request will be returned, more easily.Meanwhile, we can observe that through allocating weight to the each part of the query, we can allow the user to define the importance and priority of each characteristic for the query.
The organization of this paper first explains the required primary concepts such as object oriented databases, fuzzy concepts and fuzzy object oriented database.We then review the carried out works in this regard.Next, we present the proposed method and we will analyze and apply this approach in the following section.Finally, the technique is applied to some test data and concluding remarks are given in the last to summarize the contribution of the paper.

Object oriented database
During the past few years, there have tremendous efforts on implementing fuzzy concept on object oriented programming.Afshani et al. (2012) presented a new template based on fuzzy-UML concept for some of C4ISR products such as Logical Data Model (OV-7), Operational Event/Trace Description (OV-6c) and Systems Event/Trace Description (SV-10c).To explain further, fictional Fast Pass system used at OilCo gas stations was used to demonstrate details of the proposed model.
Designing a database in an object oriented technique, which helps presenting the mentioned base in the presented mechanisms frame by this model such as class, inheritance, grouping, etc.
The data in this database becomes the objects in this model which will be connected to each other in various ways and various operations will be possible such as data entering, deleting, adding, updating and exploiting data through exchanging messages between the objects (Unamo et al., 1998;Ma, 2005).

Fuzzy Sets
In the real world, we normally understand and handle most of the concepts in a fuzzy way representing inaccurate, unobvious and ambiguous terms.Despite the fact that terms such as hot, cold, long, short, old, young and etc., do not represent any special number, human mind understands everything quickly and in a flexible way and manipulates them to make decisions and conclusions.Yet, the machines only understand the numbers, which are precise and accurate.There are many attempts to acquire the secret of these capabilities and implement them in computers as much as possible (Zadeh, 1975).Due to the fact that our mind acts in another way, in the beginning, we need to create new logics and multi-value innovations and fuzzy logic is one of them.Entering fuzzy logic in databases, especially object oriented database, opened a new horizon to database designers (Ma et al., 2004).

2.3.Fuzzy Object Oriented Database
These kinds of databases are created through allocating fuzzy concepts to object oriented databases.This allocation can happen in 3 levels of attribute, entity and class (Ma, 2005).
First level: fuzzy attribute, an attribute, which can get its amounts from a fuzzy set, such as age which can acquire being old, young, middle-age or height which can be tall, short, medium and etc.
Second level: in this level, classes can be fuzzy and a class can be recognized with a membership degree to a range [0,1] as a subclass of a super class.
Third level: objects also can be assigned to one or some classes in a range of [0,1].
In order to define a fuzzy class, it is required to add some of the definitions to the existing definitions in the classic object oriented database and these concepts and class official definition are presented according to the defined concepts in (Ma, 2005).Indefinite systems are modeled through fuzzy-UML in (Haroonabadi, & Teshnelab, 2008-9) and UML concepts are mentioned.In a general compare, the relationship among a relational database, object oriented database and fuzzy object oriented database can be found in Fig. 1.

Related work in this field
The query process refers to a procedure in which the conditioned objects are met and selected.They will be handed over to the user according to the required frame.
The syntax rule of a language query (SQL) is as follows:

SELECT <attribute list>FROM <class name>WHERE <query condition>
(1) The classic databases lacked flexibility in queries.The query condition and database content were crisp.Yet, in the fuzzy object oriented database, both query conditions and database contents can be fuzzy, so we will have flexible queries.Besides, the process of the query in these kinds of databases refers to the procedure in which some objects of the classes are selected in order to achieve both the mentioned threshold and the mentioned condition at the condition threshold.Therefore, a syntax principle of an SQL query according to the fuzzy object oriented database model is as follows (Ma, 2005): (2) In the above mentioned definition which is suggested by Ma, query condition is a fuzzy condition and all the thresholds are crisp numbers between [0,1].The threshold amount defines that which objects will be appeared as the answer at the output.It means that only objects are allowed to appear at the output where the membership degree (μ) to the answers set is equal or more that the threshold amount.Through this query language, objects can be refund that first, they are at the required threshold, met the query condition and secondly, they belong to the classes at the required threshold.
A similar language to SQL has also been presented in (Galindo et al., 2006;)  These people have reviewed the fuzzy object oriented database but none of them has suggested the operation as a grammar to carry out the fuzzy queries on the database.The queries that our approach prepares will increase the user's accuracy to find the required output through allocating a weight to each attribute of a query.

The proposed model
It was not possible for the user to prioritize the attributes in the queries in the Ma's approach and only the level of membership of each object in the related class (μ) and the fuzzy degree of those attributes could be reviewed.The proposed model of this paper allocates weight (w) to the attribute and we leave prioritizing of each attribute in the query to the user.Meanwhile we consider a status that the query conditions to be some complicated conditions, which means our suggested syntax rule of the query is as follows: (3) If we take a precise look at the above relation, we can see that the user should define three cases for each query condition: 1-The amount of an attribute (which can be fuzzy such as age attribute and amount "teenager").2-Threshold of attribute membership degree (for example, with a threshold of 0.6 it can belong to teenager class) and 3-Attribute weight (this weight represents the level of importance or priority of each attribute for the user).
The user for each query conditions follows the objects where the attribute amount matches the required threshold (after user defined the three above mentioned cases).As soon as the user carried out the query, the amount of final threshold will be calculated by the achieved amount out of the query as follows: … .
(1) In the above mentioned relation, τ i is the acceptable threshold for the attribute and i is the required weight for the attribute in the query.Now, we can calculate the required μ for each object separately and use the functions where we wrote in the database and class previously, then, multiply it in the related of the same attribute mentioned in the query.Therefore, we will calculate the final μ through the Eq. ( 5).

…
(2) In Eq. ( 5), μ i is the degree of belonging object a to an attribute 1, μ j is the degree of belonging object a to attribute 2 and μ k is the degree of belonging object a to attribute and μ final (obj.a) is the final belonging degree of object a to the set of answers.In this stage, for any object we have a degree of belonging and we should compare this degree of final belonging to the query required threshold and if the degree of final belonging is higher than the query threshold or equal to it, we can bring this object in the answer set.It means only the objects will be appeared in the answer set where they achieve the mentioned condition in Eq. ( 6) as follows,

Implementation
In this section, we explain the class's structure and finally discuss the query orders and the way to carry them out.We explain our method through an example.Consider a case where we wish to create a fuzzy class called "Persons" which keeps the specifications illustrated in Fig. 2.  Suppose that the user asks the names of all the young people through a query, the user deals with the attribute (age) here.Due to the fact that this attribute accepts also fuzzy amounts, then it would be possible to use linguistic variables such as young, middle-aged, old, etc. instead of defining the accurate age number (Zadeh, 1975).In order to response to these queries, we should define functions called "membership functions".These functions can be designed as pre-assumptions by the designer of the database or let the user define them him/herself.The membership functions are created for the attributes amounts according to Eq. ( 7).For the trapezoidal number of T(a,b,α,β) which can present our required attributes, if the designer or the user of the database enters a, b, α and β, his/her membership function is created according to the relation 7.
( ) For instance, if we consider people aged between 18 to 28 absolutely young, and 16 to 18 and 28 to 30 rather young, then, we can present it through fuzzy trapezoidal numbers (18,28,2,2) as the young.So, we can define the concepts of middle-aged and old through the following fuzzy numbers of Mid(60,90,10,5) and Old(55,95,5,5).
The membership function of each set accepts the person's age as an input and calculates the level of belonging of that person to the set.So, we can consider Fig. 4 for the age attribute.

Fig. 4. Fuzzy value for Age Attribute
We can consider the above technique for weight, light, average and heavy weight as it is mentioned in Fig. 5.
Fig. 5. Fuzzy Value for Weight Attribute Finally, we consider the height as short, medium and tall as it is mentioned in Fig. 6.

Fig. 6. Fuzzy Values for Height Attribute
Example 1: list the name of all the tall people (τ=0.7 and w=0.8) and heavy (τ=0.5 and w=0.2) and also middle-aged(τ=0.3 and w=0.1).According to Eq. ( 3), we should carry out the following query, Now, we should apply the following functions: μ-Age-Mid, μ-Weight-Heavy and μ-Height-Tall according to Eq. ( 7) for recalling all the objects and after achieving all the amounts of μ.Using Eq. ( 5) yields final μ for all the objects.Therefore, we have, (5) We will calculate the amounts of the final membership degrees for obj2 and obj3, respectively.Eq. ( 9) shows the results.
μ-final (obj2) = 0.65 , μ-final (obj3) = 0.18 (6) Now, we calculate the final-threshold according to the Eq. ( 4) to compare the object membership degree.It would be obvious that obj.1 and obj.3 will be appeared as the output, because their membership degree is higher than the final threshold.Yet obj.2 cannot be considered at the out let response set.If we take a precise look at the example 1, we can find out about the importance of the attribute weight of the query.For instance, in this query, the obj.1 with zero membership degree belongs to the middle-aged people.Meanwhile, we know that the degree of 1 belongs to the tall people set.Due to the fact that in this query, we considered 0.1 weight for the middle-aged people and for the tall people 0.8 weight, so the importance of being tall is much more than the age and obj 1 will be presented as the output.

Data samples
We can test the query through the test amounts in Fig. 7.In this paper, we have presented a new fuzzy grammar for fuzzy queries on the object oriented database.The proposed model of this paper has been able to make the necessary influence and the priority of each attribute in query result through allocating weight to the available attributes in the query.As we have observed, the user could find all the required objects through applying the linguistic variables without dealing with the numbers through the proposed model.We have used object and class concepts to define some functions in the class without any need to receive any digital parameters.We could establish the access to the required variables of the class and carried out the operation.Our suggested approach presents a better workability in huge and heavy databases and this grammar facilitates fuzzy queries.
<attribute list> FROM <class 1 WITH threshold 1 , …, class m WITH threshold m > WHERE <query condition WITH threshold>

Fig. 2 .
Fig. 2. Persons Class that is Fuzzy Now, we create the illustrated instances out of Persons class.