1、1A Study on Database Fuzzy Query Method in SQL(Department of Computer Foundation Studies,Shenyang Institute of Engineering,Shenyang,Liaoning, 110136 China) Abstract: The previous work analyzes its simplicity, inquires the multi-relational query, inquires composite inquires, sub-query etc, so as to s
2、olve the problem of the influence of fuzzy to some extent. However, logical connection always or Zadeh Based on fuzzy logic, this paper introduces the fuzzy theory and the relationship of the weight to the extended fuzzy query. This kind of fuzzy inquires the solved here through the fuzzy theory and
3、 the function of the SQL combination, which will improve the fuzzy inquiry system, so that the query will be more effective. Key words: Databse fuzzy query, SQL, fuzzy thory 1. Introduction The fuzzy theory which was put forward by Zadeh in 1965 has been used in every field. Experts of the fuzzy inq
4、uires field can help extend fuzzy inquiry the fuzzy set. In general, the fuzzy inquiry in database management system is mainly based on two aspects: fuzzy database query and fuzzy inquiry based on 2classical brittle database. What is talked about here belongs to the latter evolution process. Through
5、 the use of “vagueness, impreciseness“ inquires the database will be more flexible, which is adapted to the nature and to the state of mind. Generally speaking, in natural language SQL query can be divided into the following items: (1) numerical fuzzy value; (2) the operation of the modified fuzzy r
6、elations; (3) quantification fuzzy language; (5) weight. All the above almost involve natural language inquires appearing in ceremony. Now, the fuzzy inquiry in SQL mainly focuses on (1) and (2) from home and abroad. 1 2 did a great job in simple fuzzy items, items and composition complex fuzzy cont
7、rol. Fuzzy project put forward the fuzzy inquires the transformation method of SQL query regularly help-cuts . 2. Fuzzy query with weights based on fuzzy logic conjunctions Fuzzy linguistic quantifies are introduced here as logic conjunctions instead of AND or OR. Through calculation of membership,
8、threshold and -cuts , this paper will deal with Fuzzy queries with weights based on fuzzy logic conjunctions and give the result sets according to matching degree. Generally, fuzzy SQL query can be expressed as: 3SELECT attributes FROM sourceTableName WHERE condition1 - -conditionn WITH attributes:
9、fields of relations in database; sourceTableName: single or multi-relations for retrieving records; condition1 conditionn: conditions that should be satisfied to some extend (it is known as predicates in ANSI / ISO), which can be simple, complex or composed fuzzy predicates; : threshold;-:connection
10、 relation between different conditions. As suggested by Zadeh, there are two kinds of quantifies in natural language: (1) absolute quantifies: at least two, about two and etc, which can be represented as fuzzy subsets of the nonnegative numbers (2) relative quantifies: most, at least, and etc,which
11、are represented as fuzzy subsets of the unit interval. Therefore where clause in SQL can be expressed as follows: ( condition1-conditionn ) is Q1(absolute quantifies) (condition1-conditionn ) is Q2(relative quantifies); In text retrieval, weights are used to express importance of different condition
12、s. Aw is represented as the query connected with OR, while Aw is represented as the query 4connected with AND. Here, fuzzy set A represents a query; w is a value between 0 and 1 used to represent the importance of different conditions; the larger w is, the more important A is. w = 0 means A is non-f
13、unctional; w = 1 means A is full-functional. For all the texts: Aw= w*A, Aw = 1- w*(1-A), *can be any T operator, so there is3: Here, we choose This T-operator, in essence, is qualitative; it can be defined in a discrete and orderly possibility scale 4. Therefore, weights in SQL query are defined as
14、 the following. Definition: Membership degree of attribute a Tuple t to A is represented as follows: Then we can gain the membership degree of attributes involved with weights, therefore do some study on fuzzy queries with weights based on fuzzy logic conjunctions. When Fuzzy linguistic quantifies a
15、nd weights are introduced, more flexible SQL query can be expressed as: SELECT attibutes FROM sourceTableName WHERE (condition1,conditionn) is Q1 (condition1,conditionn) is Q2 5WEIGHT weight1, weight2,weightn WITH FOR WEIGHT: importance defined by user; WITH: thresholds of different predicates, FOR:
16、 defined here as threshold of fuzzy linguistic quantifies; can be precise or fuzzy items. When Q1, Q2=all or any, the query will be translated to traditional query connected with AND or OR. There are many different methods to define membership functions (e.g. young, tall and etc.), Here, we take mem
17、bership functions of predicates as: Query: searching Emp_Id, name, Age, Height and Salary of employees in the relation “Employees” that meets: most of conditions “young, tall, salary is high” are true. Weights are given as: Age (0.8), Height (0.5), Salary (0.6); Thresholds: Age (0.7), Height (0.4),
18、Salary (0.5); matching degree (0.6). Then we make SQL query as: SELECT Emp_Id, name, Age, Height, Salary FROM Employees WHERE (Age is young, Height is tall, Salary is high) is most WEIGHT 0.8, 0.5, 0.6 WITH 0.7, 0.4, 0.5 6FOR 0.6 Through usage of positive method, it will get membership degree of att
19、ributes, and then gain the results according to matching degree through combination of SQL functions and Zadehs Computational Approach. All the relative Tables in the process of computation are as follows: Table 1: basic relation; Table 2: initial membership degree of attributes; Table 3: membership
20、 degree of attributes combined with weights. Through the help of matching degree of young, tall, salary-high with weights and SQL functions, (when ); (when ); (when ); Table 2 and Table 3 will be obtained: Take use of membership function of “most”, Table 4 will be gained according to matching degree
21、. (umost is the matching degree of every tuple that satisfying the query). Here, we just give a simple example to represent the basic principle of fuzzy SQL queries with weights based on fuzzy logic conjunctions. Obviously, this strategy can be extended to more fuzzy queries and also can be extended
22、 to web retrieval. 3. Conclusion 7Based on the fuzzy SQL inquires and the study of the fuzzy theory, the logic of fuzzy language zadeh conjunction quantified, not the traditional OR. And for this kind of fuzzy inquires the solution is to use the fuzzy theory, combining with the SQL function and posi
23、tive or reverse modeling, nested inquires fuzzy logic connections given below will further research involving gathered function. References 1 Zhou Hong, Xu Xiao-Bang, Wang Li-yu, “The Design of Database Query Tool Based on the Fuzzy Algorithm”, Application Research of Computers, Institute of Compute
24、r Reseach,Sichuan Pro. , 2010. 18(5), pp.15-17. 2 Zhu Rong, “Research of Query Technique Based on Fuzzy Theory”,Application Research of Computers, Institute of Computer Reseach,Sichuan Pro.,2010. 20(5), pp.8-29. 3 Shyi-Ming Chen, Woei-Tzy Jong,”Fuzzy Query Translation for Relational Database Systems
25、”, IEEE Transaction on System and Cybernetics, USA 1997. 27(4), pp.714-720. 4 Shyi-Ming,Yun_Shyang Lin,”A new method for query processing in relational database systems”, Cybernetics and System, 2002.33(1),pp.447-482. 5 Ying-Chao Zhang, Yi-Fei Chen, Xiao-Ling Ye,”Weighted 8Fuzzy Queries in Relational DataBase”,Lecture Notes in Computer Science,2005.3614,pp.430-440.