






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Abstract: Databases are very important sources for storing huge size of data. Today, yearly produced information is expressed as multiple size of the amount that produced before. Retrieving correct data is as important as storing it. At this point, querying becomes more important. Classical SQL queries return a record only if the database has a record which satisfies all search criteria. However, the user mostly wants to see similar records when there is no perfect match. For this reason, studies are focused on flexible SQL queries. In this sense, fuzzy logic can play an important role since it maintains the idea that there may be interval values between true and false, contrary to the logic of Aristotle. Genetic algorithm based database querying is another flexible querying approach to the mentioned problem. In this work, both approaches are applied on a sample real-estate database and the results are compared while discussing the efficiency of the two methods. Key words: Flexible querying, fuzzy logic, genetic algorithm.
Today, the information generated increases day by day and this increment in generated information for each year is expressed in folds. The sources where the generated information is kept and the types of processing gain importance in this parallel. This is because; it is not an easy process to access the right information among a very large amount of data. In order to retrieve data kept in databases, Structural Query Language (SQL) queries are used. Those queries provide great convenience to access the information sought in the database. In order to find solutions to this problem, the fuzzy set theory, contrary to the logic of Aristotle, is an approach advocating that there is not only true or false in the world but there might be partially true or partially false as well. Therefore, a proposition can be completely true or completely false as it can be partially true or partially false. According to the fuzzy set theory, if we assume true as 1 and false as 0, a fuzzy proposition can be true with a ratio of 0.3 and false with a ratio of 0.7. This flexible approach brought by fuzzy logic constitutes a base also for the studies on flexible queries. These studies aim at making the queries fuzzy in value ranges instead of defining them with absolute values. In this way, the user may be presented with values close to their search criteria. In order to reach the right data in large databases, another proposed approach is the retrieval of data based on genetic algorithm. The Genetic Algorithm is a powerful algorithm developed to find solutions to NP-hard problems. In cases when a solution to very large and complex problems cannot be found, the genetic algorithm is a very good alternative to generate reasonable solutions. The genetic algorithm, with its embedded features like “regeneration”, crossover and mutation, which model the transfer of the characteristics of living creatures to new generations, may generate a solution close to the best, if it is not the best one. One of the greatest advantages of the genetic algorithm is trying to find a better solution after its each random solution generation process. The idea of querying a database with the genetic algorithm approach is based on presenting the user with the best records among the certain records that are retrieved after being scored according to the search criteria by using the characteristics of the genetic algorithm. Another point of focus for the studies on fuzzy databases was the fuzzy querying languages. In one of these studies, a flexible querying language FSQL (Fuzzy SQL) was developed for the purpose of data mining. FSQL is not in itself a new query language. FSQL was developed as an extension to SQL. Here it is focused on fuzzification process of SQL commands such as SELECT, INSERT, DELETE, UPDATE. Another query language developed with a fuzzy logic base is PFSQL. The system is managed by a driver. This driver performs PFSQL
operations through JDBC API software. PFSQL has been further developed with studies done over time. In 2011, Skribic et al. published a detailed study about PFSQ
The requirement for SQL queries to be expressed in absolute values reduces the possibility of achieving the most accurate information in the systems with a large number of parameters. In the case that all criteria are determined, it will be highly probable that there will not be any record providing all the requirements. On the other hand, in the case that few criteria are selected, it is very likely that a large number of records will be returned and accessing the correct information among all these records by the user will cause loss of time. Besides, it is considered to be a problem from the viewpoint of the user that it is not possible to put the returned records in an order. Genetic algorithm is an intuitive algorithm that can give very good results for the solutions of problems with large number of parameters or with a high level time complexity. Having hundreds of thousands of records in real estate query systems, and large number of criteria such as price, number of rooms, heating type, number of bathrooms, distance to school, distance to transportation, etc. makes it reasonable to use genetic algorithm. The developed system gets from the user exact values instead of a range of values. It performs a query on the database based on the values it has received, presents the user the records, if any, meeting the determined criteria. If there is not any record satisfying the criteria the user wants, certain number of records which are the closest to the criteria entered with the developed genetic algorithm based query are presented. The interface of the developed system is shown in Fig. 3.
Fig. 1. Structure of the genes in the system. The genes used in the developed genetic algorithm based system consist of two components. One of them is the Id value of the record in the database and the other is the similarity ratio (B) of the record to the search criteria. Similarity ratio is the sum of values for all criteria calculated with the equation number(10). The gene structure used in the developed genetic algorithm is shown in Fig. 1.
Assume that operations are performed on a data set of 5000 records. First, 5000 records are retrieved from the database. Then by calculating the convenience ratio based on the attributes of each record, the convenience of the record to the search criteria are determined. After performing this operation for all 5000 records, each record is transformed to 10-gene chromosomes as Id and similarity ratio. The initial population is constructed in this way. After the initial population is constructed, convenience values and ratios are calculated for each chromosome. Among 500 chromosomes, 4 of them with the highest convenience value are transferred to the new generation as elite entities. Then it is decided whether to make a crossover or not according to the crossover probability. If crossover is to be done, randomly selected 3 genes of randomly selected two chromosomes are crossed over. If crossover is not to be done, two entities are transferred to the new Id B
a) Flow diagram b) Basic algorithm Fig. 4. Flow diagram of the system.
The study was developed with PHP programming language and MySQL database. Mutation characteristic of the genetic algorithm was not used in the system developed with the genetic algorithm as it was not suitable to the structure of the problem. This is because as the system performs operations on existing records it is very likely to obtain non-existing records with mutation. Besides that all other characteristics of the genetic algorithm such as elitism and crossover were used. Moreover, when selecting entities, to increase the chance of selecting good ones roulette wheel selection method was used. In the developed fuzzy logic based system, triangular membership function among the membership functions of fuzzy logic was used. According to this, linguistic variables received from the user are compared with database records with the help of fuzzy expressions defined in the system. As a result of this comparison, it is determined how similar is the record to the search criteria. The developed system gets from the user linguistic expressions like expensive, cheap, far, close instead of a value range and weighs each criterion from 1 to 5. Fuzzy logic based flexible query system presents the closest match of records based on the criteria entered with those expressions to the user according to the similarity ratios. This study was tested on seven central districts of Ankara. The system was tested on a sample database where records of 100000 rental property were kept. Test operations were performed separately on data sets
of 20000, 5000 and 1000 retrieved from the database. When performing the search process, operations were conducted on price, floor area, distance to school, distance to subway, distance to public transport, distance to hospital and distance to shopping center parameters of the records. The number of rooms, the number of bathrooms and the heating type criteria were not used as they are not suitable to the fuzzy logic based system considering two systems would be compared to each other. Each field can be weighted in the range of 1 to 5 according to importance. Weighting can be done by grading each and every criterion with Not Important, Somewhat Important, Important, Very Important and Extremely Important. This operation provides the user the opportunity to grade the defined parameters. The basis of fuzzy logic is based on fuzzy expressions. When fuzzificating the related fields the linguistic expressions such as very close, close, far, very far were used. The number of these linguistic expressions and the values they can take for each criterion are the values that may affect the result directly. In the genetic algorithm based system, because each chromosome consists of 10 genes (records), an initial population consisting of a number of chromosomes up to one tenth of the determined data set was constructed. The maximum number of iterations was selected as the 1/50 of the size of the population, crossover probability as 0.7. Attention was paid to use the same parameters for both systems during the test. For example, when 850 was selected for price on the genetic algorithm based system, on the fuzzy logic based system expensive value corresponding to this value was selected. The same operation was performed for all criteria. The parameters selected for testing in the genetic algorithm based system are shown in the Table 2. The counterparts of these parameters in the fuzzy logic based system are shown in Table 3. Table 2. Example Search Criteria 1 Criteria Value Degree of importance Number of roo ms Type of heating Number of bathrooms not important not important not important Price 850 5 Floor area 210 5 Distance to subway 500 3 Distance to hospital (^3000 ) Table 3. Example Search Criteria 2 Criteria Value Degree of importance Number of rooms not important Heating type Number of bathrooms not important not important Price Expensive 5 Floor area Too big 5 Distance to subway Walking distance 3 Distance to hospital far 2 Distance to school Walking distance 4 Distance to shopping center close 4 Distance to public transport Close 3 These parameters were tested in both systems on data sets of 1000, 5000 and 20000. Furthermore, the test operation was performed with all criteria, with only three criteria (price, floor area and distance to subway) and with two criteria (price, floor area). If we look at it as an example, when the tests were
Fig. 7. The results obtained when the search criteria shown in table 3 were tested with fuzzy logic on 5000 records. At the end of the testing process, it was found out that the number of criteria directly impacts the success of the system. The success obtained decreases as the number of criteria increases as shown in Table 4. While a record with a maximum 92,33% success ratio can be obtained when genetic algorithm is applied on 20000 records with all criteria are selected, a record with 99,3% similarity ratio can be obtained when only 2 criteria are selected. When operation is performed on 20000 records by selecting 3 criteria, a record with a success ratio of 94,84% can be obtained. Table 4. Different Search Criterion and Obtained Results with Genetic Algorithm Based System Population (^) Number of Number of Max. size^ iteration criterion/Criterions success(%) Different criterion numbers 20000 400 7 92. 20000 400 3 94. 20000 400 2 99. Different population size with 2 criterion 20000 400 2 96. 5000 100 2 95. 1000 20 2 91. Different population size with 3 criterion 20000 400 3 94. 5000 100 3 91. 1000 20 3 87. Different specific criterions 20000 400 96. 5000 100 price and floor area 95. 1000 20 91. 20000 400 99. 5000 100 distance^ to^ hospital^ and^ 97. 1000 20 distance to subway^ 96.
Table 5. Different Search Criterion and Obtained Results with Fuzzy Logic Based System Number of records The best record that found(%) Average of top ten records(%) All criterion (^20000) 90.61 79. 5000 90.61 76. 1000 78.42 68. pric e and floor area 20000 100 100. 5000 100 99. 1000 100 99. Price, floor area and distance to subway 20000 5000 100 100
1000 100 95. Considering the low probability of a record satisfying many criteria at the same time, this is evaluated as a reasonable result. According to this, the success rate that is obtained as a result of testing only with two criteria gives better results than testing with 3 or more criteria. Another area affecting the success of the system was determined as the size of the population. As the number of population increases the success ratio also increases as shown in Table 4. In another words, if the user compares the search criteria with more records, the probability of finding the property searched for or close records increases. According to this, when a system is tested on 20000 records, better results are obtained compared with 5000 records. While a success ratio of 96,4% is obtained when the operation is performed on a data set of 20000 records by selecting only 2 criteria, a success ratio of 91,46% is obtained when the operation is performed on a data set of 1000 records. In the same way, while a success of 94,84% can be obtained when the operation is performed with 3 criteria when 20000 records are selected, a success ratio of 87, 57% was obtained when operation was performed on 1000 records. Another factor affecting the success ratio is the characteristics of the data kept in the database. Whether the criterion specified by the user is in the database or the difference between maximum and minimum values are also factors affecting success as shown in Table 4. The criteria of price and floor area are the ones the difference between their maximum and minimum values is the least. Besides this, the criteria of distance to hospital and distance to subway are the ones the difference between their maximum and minimum values are the greatest. While in situation 2 prices and floor area criteria were tested, in situation 3 the distance to hospital and the distance to school were tested. When the results of the two situations are compared it is seen that Situation 3 gives better results. While the success ratio is 96,4% in Situation 2 it increases up to 99,3% in Situation 3. The number of records the search criteria are tested on has a direct impact on the result as shown in Table
user repeating the search again by changing the parameters continuously. Presenting the returned result to the user according to the similarity ratios considered to be another advantage of both systems. From the genetic algorithm point of view, making an optimization between the number of iterations and the number of population is important in terms of obtaining better results. This is because both parameters affect the performance of the genetic algorithm directly. Besides this, changing the number of genes in an entity is important for increasing the number of records presented to the user. Besides presenting the chromosome having the highest ratio in the final population to the user, it is considered to be a more efficient method to find the highest values in all chromosomes and to present them to the user to get better results. From the fuzzy logic point of view, defining the linguistic parameters in a better way or letting the user to define them is a very important issue. Because the meanings expressed by linguistic parameters vary from person to person, while having the user define them by himself or herself means a more flexible system, it is also important for obtaining better results.
[1] Ma, Z. M., & Yan, L. (2007). Generalization of strategies for fuzzy query translation in classical relational databases_. Information and Software Technology, 49_ , 172 – 180. [2] Ata, A., & Kurnaz, S. (2011). Creating and applying a model for human resources candidate selection system by using a fuzzy database and fuzzy queries. Journal of Aeronauticd and Space Technologies, 5(1), 41 - 52. [3] Zongmin, M. (2006). Fuzzy database modeling of imprecise and uncertain engineering information. Collage of Information Science & Engineering. China: Northeastern University. [4] Zadeh, L. A., & Kacprzyk, J. (1992). Fuzzy logic for the management of uncertainty. Library of Congress Catalogin-in-Publication Data Presss , 645 - 672.