1. DETERMINING MEMBERSHIP FUNCTION VALUES TO
OPTIMIZE RETRIEVAL IN A FUZZY RELATIONAL
DATABASE
Directed Research Report
Directed By: Dr. Lorraine M. Parker
Shweta Sanghi
May 2005
2. Table of Contents
Page No.
1. Introduction……………………………………………………………………………………................1
1.1. Overview of Fuzzy Relational Databases……………………………......................................2
1.2. Overview of Previous work……………………………………………...................................5
2. Machine Learning Methods to Adjust Weights………………………………………………………….8
3. Methods of Constructing Membership Function……………………………………………………….10
3.1. The Fuzzy Linguistic Approach to Fuzzy Set……………………………………………….10
3.2. Fuzzification………………………………………………………........................................11
3.3. Membership function determination…………………………………………………………12
4. Project Description…………………………………………………………….......................................15
4.1. Testing…..……………………………………………………………………………………15
4.2. Results………………………………………………………………………………………..19
4.3. Obstacles……………………………………………………………………………………..23
5. Future Work………………………………………………………………………………………….…24
References…………………………………………………………………………………….………...25
Appendix A. Stored Procedures………………………………………………………………………...27
Appendix B. Source Code………………………………………………………....................................37
Appendix C. Statistical Method to Construct Membership Weight for Images………………………..79
Appendix D. Instructions to install the Fuzzy Database Research on the Local Machine....................101
3. 1. Introduction
Computers have made tremendous progress in the past few decades. They are now
decidedly superior to human beings in speed and preciseness of calculation. However, computers
do not always satisfy users’ requirements. One reason for this dissatisfaction is the lack of
vagueness or imprecision, which are remarkable characteristics of humans. Imprecision is always
part of our thinking and reasoning.
As an approach, fuzzy database systems, which are able to represent and manipulate
imprecise information, have been presented. In these systems, imprecise information can be
stored using fuzzy linguistic terms (e.g. young, big) which are frequently used in daily
conversation. Although these words are ambiguous or uncertain, communities can agree on their
meanings.
This paper presents an overview of fuzzy relational database theory and analyzes the
previous work on a particular fuzzy database implementation [1] designed to retrieve images
using fuzzy constructs whose common-language descriptions were defined by the consensus of a
particular user community. Further, this paper describes research aimed at determining the best
way of setting the membership values via feedback from the community. The desire is to expand
the functioning level of the current prototype in order to implement “smart” database retrieval. It
is proposed to determine membership values using the Direct Rating method. This method of
determining membership function values (described in section 3.3) is then compared with the
original prototype to determine which method is better.
4. 1.1 Overview of Fuzzy Relational Database
Conventional relational database systems are based on crisp data, which is precise. Fuzzy
relational databases extend the conventional relational database model to allow for representation
of imprecise data.
A fuzzy set is created to describe the linguistic variables in more detail. The linguistic
variable “age,” for instance, may have overlapping categories (members) of “young,” “very
young,” “middle age,” “old,” and “very old.” Once these categories or members are defined, the
fuzzy set is obtained, and a membership function is then developed for each member in the set.
Fuzzy logic and fuzzy sets were first introduced by Lotfi A. Zadeh [2]. Fuzzy sets were
derived by generalizing the concept of set theory. Fuzzy sets can be thought of as an extension
of classical sets. In a classical set (or crisp set), the objects in the set are called elements or
members of the set. An element x belonging to a set A is defined as x ∈ A, an element that is not
a member in A is noted as x ∉ A. A characteristic function or membership function µA(x) is
defined as an element in the universe U having a crisp value of 1 or 0. For every x ∈ U,
1 for x ∈ A,
µ A ( x) =
0 for x ∉ A.
This can also be expressed as µ A ( x ) ∈ { 0,1}
In crisp sets the membership function takes a value of 1or 0. For fuzzy sets, the membership
function takes values in the interval [0, 1]. The range between 0 and 1 is referred to as the
membership grade or degree of membership [5].
5. A fuzzy set A is defined as:
A = { ( x, µ A ( x ) ) | x ∈ A, µ A ( x ) ∈ [ 0,1]}
Where µA(x) is a membership function belonging to the interval [0, 1]. Fuzzy set theory has
equivalent operations to those of crisp set theory. It includes functions such as equality, union
and intersection [1].
A Fuzzy Relational Database extends a normal relational database by adding fuzzy logic,
fuzzy data and membership functions. Membership functions can be defined as the degree of the
truthfulness of the proposition. For example, the predicate “John (X) is tall (A)” is represented
by number in unit interval µA(x). µA(x) = 0.7 means that John is tall to the degree 0.7. It is
different from probability.
The use of relations is one method of adding fuzzy selection criteria to a query. The rows
contain data that is interpreted according to the elements in them and their fuzziness. For
instance, consider the following height table.
Name Height
John 6’0’’
Bill 5’0’’
Janice 4’0’’
Fred 5’8’’
Meri 5’6’’
The elements in the height column are crisp values because they give the exact height of the
individual. A range query could be created to find people within a certain range of heights, but it
would be more convenient to define the range as a relation:
6. SELECT NAME FROM HEIGHTS
WHERE HEIGHT IS SHORT;
If SHORT was defined equal to 5’0’’ in the database, only “Bill” would be selected since he is
the only short person in the group. A query could also be formulated to include different sets of
range, that is, people who are VERY SHORT or of MEDIUM height. One way of approaching
this is to create a relation that defines SHORT and its relationship to the other heights. In effect,
we are defining the membership function for the fuzzy attribute SHORT.
Height Short Membership
4’00’’ 0.00
4’4’’ 0.10
4’8’’ 0.50
5’0’’ 1.00
5’6’’ 0.50
5’8’’ 0.10
6’0’’ 0.00
The query would then receive names from the list based on the threshold. For instance, if we set
our threshold for SHORT to be 0.50 or greater, then the query would return both Bill and Meri.
A querying language called SQLf [3] has been developed to support a wide range of
fuzzy queries (i.e., fuzzy predicates are introduced into the language wherever possible) while
also adhering to the conventions used in SQL. The basic principle of SQLf is the introduction of
fuzziness into the SELECT-FROM-WHERE block of SQL. Fuzziness is introduced at two levels
within the WHERE condition, both in the predicates themselves and in the way they are
combined (in the “connectors like and, or, etc”). To illustrate, consider these relations:
7. Employee (Emp#, E-name, Salary, Job, Age, City, Dept#) and
Department (Dept#, D-name, Manager, Budget, Location)
The query “Find the best 5 employees from Chicago who are well-paid and who are working in a
high budget department” may be expressed as:
1. SELECT E.Emp, E.Name
2. FROM Employee E,Department D
3. WHERE E.City=”Chicago” AND E.Salary=”well paid” AND D.Budget=”high”
4. AND E.Dept#=D.Dept#
In the above select statement, fuzziness is introduced in the line number 3 by the use of words
well and high.
1.2 Overview of previous work
A fuzzy relational database [1], which uses a natural language querying system to retrieve
images whose common-language descriptions are defined by the consensus of a particular user
community, was previously developed.
The architecture of this relational database system required two layers to process fuzzy
queries. The first layer was a RDBMS architecture and the second layer was a user interface
layer of stored procedures in SQL Server to process the fuzzy queries. To query the database,
SQLf was used. The syntax to query the database was
SELECT (attribute list)
FROM (relation List)
WHERE (fuzzy conditions)
Fuzzy conditions are conditions which use fuzzy predicates such as EYE_COLOR =
SLIGHTLY BLUE. For each image, each of the possible values of a fuzzy attribute and its
8. corresponding membership weights were listed in a tuple as shown in Table 1. The features used
in the implementation were “eye color” and “face width”. For eye color, possible values were
green, blue and brown. For face width, values were broad, average and narrow. A list of fuzzy
modifiers and their synonyms was developed. The modifiers selected (to be used with either
attribute) were “very”, “medium” and “slightly”. Each modifier was assigned a corresponding
range on the (0, 1) membership interval as shown in Table 2. Thus, using the two tables, a query
requesting people with “light blue eyes” would return all of the images with EYE_COLOR =
BLUE and a membership value between 0.0 and 0.29. To illustrate, an image of a person with
eyes that are predominantly green with just a hint of blue and no trace of brown could be
represented in the database as shown in Table 1.
IMAGE_ID EYE_COLOR WEIGHT (µ)
1 GREEN 0.8
1 BLUE 0.3
1 BROWN 0.0
Table 1: Using Membership Values (Weights) for Each Attribute
Modifier Range_From Range_To Midpoint
“Very” 0.75 1.0 0.87
“Medium” 0.30 0.74 .52
“Slightly” 0.0 0.29 .20
Table 2: Modifier Ranges and Midpoints
Random values between [0, 1] were assigned as weights or membership values to each
attribute of every image when the program was initialized for each particular user community.
Each modifier had a threshold value that was at the midpoint of the modifier’s range. Threshold
value was designed to steady each attribute’s membership value within the modifier ranges so it
accurately represented each community’s consensus. The users, after viewing the result of their
9. query, provided the feedback as to whether the image met their criteria or they believed the
image would be better defined using a stronger or a weaker modifier. According to the user’s
response, the weight of the attribute was increased or decreased by 0.01. For example, after
viewing the result of query EYE_COLOR = VERY BLUE, if the user decided that the image
should be defined by a stronger modifier then the weight was adjusted towards the threshold for
very blue but if the user decided that the image should be defined by a weaker modifier then the
weight was decreased by 0.01. Thus, by adjusting the membership weight so that it was as deep
in the range as possible (i.e., at the midpoint), the community opinion was strengthened with
concurring feedback. This method of constructing membership value from the subjective
information is denoted as the Random Method.
The Fuzzy Relational Database was designed to have a natural query language interface
where a user would enter a query such as, “List names of the persons with very brown eyes”. The
natural query language interface parsed the user query into the actual query and the
modifier/attribute pair. This data was stored into separate data files, which the fuzzy relational
database took as input. It then created a fuzzy query, queried the database and produced the
result. After getting user feedback, the membership weights were adjusted. This process went on
until a community consensus was reached.
2. Machine Learning Methods to Adjust Weights
The field of machine learning is concerned with the question of how to construct
computer programs that automatically improve with experience. Machine learning is said to
occur in a program that can modify some aspect of itself, often referred to as its state, so that on
a subsequent execution with the same input, a different (hopefully better) output is produced.
10. Machine Learning is defined as, “A computer program is said to learn from Experience E
with respect to some class of tasks and performance measure P, if its performance at tasks in T,
as measured by P, improves with experience E.”[4]
Learning systems learn through use of some sort of feedback or evolution or reaction to
its response of experience E. Broadly speaking machine learning can be divided into two types
Supervised Learning: Supervised learning is where the learning algorithm is provided
with a set of inputs for the algorithm along with the corresponding correct outputs, and
learning involves the algorithm comparing its current actual output with the correct or
target outputs, so that it knows what its error is, and modify things accordingly. For
example, supervised learning is used in back propagation algorithm to train neural
networks.
Unsupervised learning: Unsupervised learning is where the system is not told the "right
answer". It is not trained on pairs consisting of an input and the desired output.
Unsupervised clustering algorithms can be used to train the system.
The purpose of the current fuzzy database implementation is to retrieve images by using
fuzzy queries whose common-language descriptions are defined by the consensus of a particular
user community. In everyday life, these language descriptions are subjective. A person may be
described as having dark brown hair and a narrow face by one user and other user can describe
that person differently. Therefore the terms like “dark brown” and “narrow” are not objective
definitions but rather reflect a person’s (or a group’s) definition of those terms. These definitions
depend on factors like culture and experience, and may change over time. Although it is difficult
11. to design a system which satisfies each user’s perception of facial definitions, a consensus can be
reached so that it satisfies most users of that community. Since learning is based on feedback
provided by the user community and the system does not know the right answer, it is using
unsupervised learning.
According to the definition of machine learning, the system can defined as
• Task T: Retrieval of images according to the criteria defined
• Performance Measure P: Percent of community satisfaction
• Training Experience E: User feedback
3. Methods of Constructing Membership Function
A membership function (MF) is a curve that defines how each point in the input space is
mapped to a membership value (or degree of membership) between 0 and 1. The input space is
sometimes referred to as the universe of discourse, a fancy name for a simple concept.
12. Summary of Membership Functions
• Fuzzy sets describe vague concepts (fast runner, hot weather, weekend days).
• A fuzzy set admits the possibility of partial membership in it. (Friday is sort of a weekend
day, the weather is rather hot).
• The degree an object belongs to a fuzzy set is denoted by a membership value between 0
and 1. (Friday is a weekend day to the degree 0.8).
• A membership function associated with a given fuzzy set maps an input value to its
appropriate membership value.
3.1 The Fuzzy Linguistic Approach to Fuzzy Set
The linguistic approach is Zadeh’s original idea [2]. It is based on two main concepts: the
linguistic variable and the linguistic term. A linguistic variable represents a concept that is
measurable in some way, either objectively or subjectively, like temperature or will. Linguistic
variables are characteristics of an object or situation. Linguistic terms rate the characteristic
denoted by one linguistic variable. A linguistic term is a fuzzy set, and the linguistic variable
defines its domain.
Every adequate representation of fuzzy sets involves the basic understanding of five
related conceptual symbols:
• the set of elements θєΘ, as in “image” from “group of images”
• the linguistic variable V, that is a label for one of the attributes of the elements
θєΘ, as in “eye color” of “image”;
• the linguistic term A, which is an adjective or adverb describing the linguistic
variable, which is a subjective measure of V, as in “blue” describing “eye color”;
13. • a referential set X С R, that is a measurable numerical interval, for the particular
attribute V, as in “[0,100] blue” for “eye color”;
• a subjective numeric attribution µA(θ), of the membership value, i.e., the
membership degree of the element θ, labeled by the linguistic variable V as
described by A.
3.2 Fuzzification
The first step in every fuzzy system consists of converting the inputs from the traditional
crisp universe to the fuzzy universe. This step is known as fuzzification or fuzzy encoding, and
identifies that there is an acceptance of uncertainty assigned to the input value. Every input value
is associated with a linguistic variable. For each linguistic variable, it should be assigned a set of
linguistic terms that subjectively describe the variable. Most of the time, linguistic terms are
words that describe the magnitude of the linguistic variable, as “hot” and “large”, or how far they
are from a goal value, as in “exact” or “far”. Each linguistic term is a fuzzy set and has its own
membership function. It is expected that for a linguistic variable to be useful, the union of the
support of the linguistic terms cover its entire domain. It is also expected that there some
intersection between the support of linguistic terms that describe similar concepts. So, when
talking about temperature, for instance, one would expect to see some values that will be, at the
same time, described as “cold” and “freezing”. Usually, adjacent linguistic terms have 10 to 50%
superposition. Given all the fuzzy sets which correspond to each linguistic variable, fuzzification
means to determine the membership value of each input value in each fuzzy set.
3.3 Membership Function Determination
14. Mainly, there are six methods used in experiments with the aim of constructing
membership functions [14]:
Polling: do you agree that John is tall? (Yes/No)
Direct rating (point estimation): classify John according to his tallness. In general, the
question is: “How F is a?”
Reverse Rating: identify the person who is tall to the degree 0.6? In general,
identify a who is F to the degree µF (a).
Interval Estimation (set valued statistics): give an interval in which you think the height of
John lies.
Membership function exemplification: What is the degree of belonging of John to the set
of tall people? In general, “To what degree a is F?”
Pairwise comparison: which person John or Joe, is taller (and by how much?)
1: Polling
In polling one subscribes to the point of view that fuzziness arises from interpersonal
disagreements. The question “Do you agree that a is F?” is asked to different individuals. The
answers are polled and an average is taken to construct the membership function. Polling is also
one of the natural ways of eliciting membership functions for the likelihood interpretation.
2: Direct Rating
Direct rating seems to be the most straightforward way to come up with a membership
function. This approach subscribes to the point of view that fuzziness arises from individual
subjective vagueness. The subject is required to classify a with respect to F over and over again
in time. The experiment has to be carefully designed so that it will be hard for the subject to
15. remember past answers. The same question is asked to the same subject over and over again, and
the membership is constructed using the assumption of probabilistic errors and by estimating a
few key parameters as is usual for this type of construction. Chameau & Santamarina (1987a)
use several subjects and aggregate their answers as opposed to asking a single subject same
questions over and over.
3: Reverse Rating
In this method, the subject is given a membership degree and then asked to identify the
object for which that degree corresponds to the fuzzy term in question. This method can be used
for individuals by repeating the same question for the same membership function as well as for a
group of individuals. Once the subject’s (or subjects’) responses are recorded, the conditional
distributions can be taken to be normally distributed and the unknown parameters (mean and
variance) can be estimated as usual. This method also requires evaluations to be made on at least
interval scales to determine membership function.
4: Interval Estimation
The subject is asked to give an interval that describes the Fness of a. Let Ii be the set-
valued observation (the interval) and mi the frequency with which Ii is observed. Then R = (Ii;
mi) defines a random set. It means that mi population is defining the interval in which the fuzzy
term lies. The rest of the population defines the different interval for the Fness of a.
5: Membership Exemplification
The subject is asked to write the degree which is appropriate for “large”, “very
large”, “small” on scale of 0 to 100. The same question is asked to the group of individuals. The
results are analyzed to determine membership function.
16. 6: Pairwise Comparison
The subject is asked a question “which is a better example of a bird: an eagle or a
pelican?”, and based on answer (say, an eagle is chosen) to that question, another question is
asked: “How much more of a bird is an eagle than pelican?” Weights are then derived from the
principal eigenvector of the square reciprocal matrix of pairwise comparison between all
contributing attributes.
In all of the elicitation methods, Chameau & Santamarina [15] obtain the membership
functions based on averaging or aggregation of the responses from several assessors. In that
sense they do not subscribe to the individualistic interpretation of fuzziness. Chameau &
Santamarina justify this approach by assuming that fuzziness is a property of the phenomenon
rather than a property attributed by the observer. All of the above described approaches are
called manual methods of determining membership function because expert/experts are required
to obtain membership function. All the manual approaches suffer from the deficiency that they
rely on very subjective interpretation of words, the foibles of human experts and generally all the
knowledge acquisition problems that are well documented [6] with knowledge based systems.
4. Project Description
This research aims to determine the best way of setting the membership values using
feedback from the community for the fuzzy relational database. The purpose of the fuzzy
database implementation is to retrieve images by using fuzzy queries whose common-language
17. descriptions are defined by the consensus of a particular user community. The fuzzy set, which is
presentation of fuzzy attribute values of the images, is determined through membership function.
How best to determine the membership function is the first question to answer? It is
proposed to construct membership values by the Direct Rating method. This approach subscribes
to the point of view that fuzziness arises from individual subjective vagueness. This method of
constructing the membership function will then be compared with the present prototype which
uses the random method as explained in section 1.2 to determine which method gives the most
user satisfaction with minimum feedback from the community.
4.1. Testing
The previous implementation was modified to alter the method of assigning the
membership value, which was based on direct rating method, for the blue eye color attribute of
each image. User feedback for both the prototypes was taken in two sessions, which were
training and testing. The user interface of both the prototypes was altered to make it user
friendly. The source code with changes can be referenced in Appendix B.
In the direct rating method, random weights were not assigned to the blue eye color
attribute of the images as was done in previous prototype [1]. In the training session, the question
put to the community was “How blue are the eyes? and they responded using a simple indicator
on a sliding scale. The left most bar on the sliding scale represented that the eyes were not blue
whereas the right most bar on the sliding scale represented that the eye were 100% blue. The
training session was comprised of 21 people. The values given for blue eye color attribute were
recorded into the database as shown in Figure 1.
18. Image 1 Scores 0-29 30-74 75-100
0 1 0 0
25 1 0 0
33 0 1 0
Frequency Distribution of Image ID 1
39 0 1 0
44 0 1 0 14
46 0 1 0
52 0 1 0 12
53 0 1 0 10
54 0 1 0
62 0 1 0 8
Frequency
65 0 1 0
6
69 0 1 0
70 0 1 0 4
71 0 1 0
2
74 0 1 0
75 0 0 1 0
86 0 0 1 0-29 30-74 75-100
93 0 0 1 Frequency Range
99 0 0 1
100 0 0 1
100 0 0 1
2 13 6
Figure 1: Scores and Distribution for Image 1
The first column in Figure 1 represents the community’s view of the degree to which
image 1 had blue eyes. Frequency distribution method was chosen to summarize the community
feedback for each attribute in order to achieve maximum user satisfaction. A frequency
distribution table was created that grouped scores into non overlapping intervals called frequency
ranges. The frequency ranges were chosen based on range values of the very (75-100), medium
(30-74), slightly (0 -29) modifiers. The number of scores that fell into each frequency range was
calculated. The counts, or frequencies, of scores were then listed in their respective frequency
ranges. The base of the rectangles in the histogram corresponds to the frequency ranges, and
19. height of each rectangle equals the number of scores in that range. The frequency histogram for
each of the 40 images can be referenced in Appendix C. Based on Table 2; each image acquired
the threshold membership value for the maximum frequency range. For example, 13 people out
of 21 chose the medium blue eye color for the image 1, while 6 people out of 21 said that the
image had very blue eyes. Therefore, the membership value of 0.52 was assigned to the blue eye
color attribute of the image id 1. Weights were similarly assigned for each of the 40 images as
shown in Figure 2.
In the random method, random weights were assigned initially to the blue eye color
attribute of the images. The training session which comprised of 21 people was conducted to
learn membership weights. Based on the community feedback, membership weight of the blue
eye color attribute of each image was adjusted as explained in section 1.2.
20. Figure 2: Membership Weights for Direct Rating Method
A testing session was conducted to compare both methods of eliciting membership values
and to determine which method gives the better community satisfaction. In the testing session,
21. the fuzzy relational database was queried for “slightly”, “medium” and “very” blue eye color of
the images based on the membership value assigned by the random method and the direct rating
method. The community was asked whether, they were satisfied with the result or not. The
percentage of user satisfaction was calculated. The percentage of user satisfaction of random
method and direct rating method can be referenced in Appendix C. The line graph in figure 3
represents the comparison of user satisfaction for 40 images. For example, for image id 1, user
satisfaction was 89% for the direct rating method and 67% for the random method.
% of User Satisfaction Comparison
120
100
% User Satisfaction
80
60 Random
Method
40 Direct Rating
Method
20
0
1 4 7 10 13 16 19 22 25 28 31 34 37 40
Image ID
Figure 3: Comparison of Percentage of user satisfaction for all images
4.2 Results
The proposed direct rating method was the better method to determine membership
function values, compared to the random method. The reasons are:
22. • The direct rating method is more efficient because it reaches consensus with fewer
iterations. For example, the random method can assign 1.0 membership value initially to
an image whose eyes are not blue. It would take at least 100 feedbacks to reach a weight
of 0.0, provided each user’s perception is the same.
• It is based on maximum vote. The threshold value is assigned based on the maximum
value of frequency distribution table.
• It achieved a higher user satisfaction in 80% cases compared to random method.
• It is efficient even for smaller communities. For random method to be efficient in all
cases, the community should comprise of at least 100 people. The extreme case for
random method will be when the random method assigns 1.0 membership value initially
to an image whose eyes are not blue. It would take at least 100 feedbacks to assign 0.0
weights, provided each user’s perception is same.
However, there were many factors that affected the results.
• The images were described by the community, not the database designers. Thus, it was
expected that each user could describe the same images differently. Therefore a term like
“very blue eye” is not objective but rather reflects a person’s definition of those terms.
These definitions depend on factors like culture and experience, and may change over
time.
• For those images that got less than 25% user satisfaction, the pictures were not very clear.
It was very hard to make out the eye color. It would have been better if the focus of the
image was more on eye. This was true for both methods. But in this real world, perfect
pictures can not be guaranteed in such a system.
23. • There were some images whose user satisfaction was between 35% and 70% for the
direct rating method because the frequency distribution of the attribute for two ranges
was very close. Although, the maximum user’s satisfaction range was picked, but over all
satisfaction was low. For example see Figure 4. Nine users out of 21 said that the eyes
were medium blue, and 10 out of 21 said that the eyes were slightly blue eye. The
membership weight of 0.2 was assigned to the image to reach maximum satisfaction but
testing revealed 44% of user satisfaction.
Image 33 Scores 0-29 30-74 75-100
0 1 0 0
0 1 0 0
0 1 0 0
Frequency Distribution of Image ID 33
0 1 0 0
0 1 0 0 12
0 1 0 0
14 1 0 0 10
16 1 0 0
20 1 0 0 8
Frequency
25 1 0 0
6
30 0 1 0
33 0 1 0
4
42 0 1 0
50 0 1 0 2
56 0 1 0
56 0 1 0 0
67 0 1 0 0-29 30-74 75-100
69 0 1 0 Frequency Range
73 0 1 0
90 0 0 1
95 0 0 1
10 9 2
Figure 4
It is suggested that frequency distribution should be recalculated by removing 0 score
value of the attribute. For example in case of Figure 4, after removing 0 score, 4 out of 15
users said that the eyes were slightly blue eye, and 9 users out of 15 said that the eyes
24. were medium blue. The membership weight of 0.52 could be assigned to the image 33.
This requires further testing.
• The community which trained the prototype and the tested the prototype was not same.
21 users trained the both prototypes. 27 users tested the direct rating method and 15 users
tested the random method. The varied community may be the one reason for not reaching
community’s consensus more than 80% for all images. There may be other reasons such
as communities may never agree that often. This requires further testing.
• The community did not define the range of modifiers. It was defined by the database
designer. One user can describe range between 25 and 35 as slightly and other user can
describe the same range as medium. One strategy could be to designate certain user as
“expert” whose opinions would be weighted more heavily than the rest of the group’s.
The expert would define the range of modifiers and educate the rest of community about
the range of modifiers. Other strategy could be learning the range of modifiers from the
community feedback. This requires further investigation.
• The slightly modifier includes those images that have no blue eye color. The results
would have improved by excluding images with no blue eye color. For example in Figure
4, only six people would have described the image as slightly, if 0 score is ignored.
It is believed that if these factors were taken into account the direct rating method would
reach higher satisfaction. But this requires more study.
25. 4.3 Obstacles
There were many obstacles that had to be overcome to conduct this research. The main
obstacle was learning and installing Microsoft .Net and SQL Server. Installation of the previous
prototype on the local machine caused lots of problems because of inadequate documentation.
Instructions to install this application locally can be referenced in Appendix D. Problems like
changes in the user interface to use a slide bar, making the user interface friendly to conduct
experiments, finding a way to display all images were other challenges that took time.
26. 5. Future Work
The research raised some questions, which can be explored in future fuzzy relational
database research.
One suggested area is in using unsupervised machine learning techniques such as Least
Mean Square algorithm or clustering techniques to adjust weights in order to reach maximum
satisfaction. Different strategies can be used to train the system. One strategy could be to
designate certain users as “experts” by community whose opinions would be weighted more
heavily than the rest of the group’s. Rather than using random values, these experts would
initially be shown the images and their descriptions would establish the initial membership
values; the remaining users would then modify the weights from that point forward. Other
strategy could be start learning by initializing weights with random values and learn until certain
percentage of satisfaction reached, then stop learning and again start learning after certain period
like after a month or year or after the level of dissatisfaction reaches a particular percentage.
Another area of future interest could be improvements in user interface. Instead of
showing whole image, the focus can be more on attribute in study. For example, while training
images for eye color, if focus would have been on eyes then results may have been better. User
interface should be improved to make it more users friendly.
Another area of interest would be defining the range of modifiers. One strategy could be
to designate certain user as “expert” whose opinions would be weighted more heavily than the
rest of the group’s. The expert would define the range of modifiers and educate the rest of
community about the range of modifiers. Other strategy could be learning the range of modifiers
from the community feedback. Another area of future interest would be to find the best method
to handle unclear pictures.
27. References
[1] Joy,Karen and Dattatri, Smita ,” Implementing a Fuzzy Relational Database and Querying
System With Community Defined Membership Values “, VCU Directed Research Report,
November 2004.
[2] Zadeh, L. A. (1965). “Fuzzy Sets.” Information and Control, 8, 338-353.
[3] Bosc, P. & Pivert, O. (1995). ”SQLf: A Relational Database Language for Fuzzy Querying.”
IEEE Transactions on Fuzzy Systems, 3, 1-17.
[4] Mitchell, Tom M. “Introduction to Machine Learning” in Machine Learning (7th ed.),
McGraw Hill Publishers, 2-5.
[5] Turksen, I.B., Measurement of membership functions and their acquisition, Fuzzy Sets and
Systems, 40:5--38, 1991.
[6] Motoda, H., Mizoguchi, R., Boose, J. H., and Gaines, B. R., Knowledge Acquisition Tools,
Methods, and Mediating Representations, Proceedings of the First Japanese Knowledge
Acquisition for Knowledge-Based Systems Workshop: JKAW-90, Ohmsha, Japan.
[7] Norwich, A.M. & Turksen, I.B., The construction of membership functions, Fuzzy Sets and
Possibility Theory: Recent Developments.
[8] Watanabe, N., Statistical Methods for Estimating Membership Functions, Japanese Journal of
Fuzzy Theory and Systems, 5(4), 1979.
[9] John, R. I., Fuzzy Inference Systems: Problems and Some Solutions, De Montfort University
Computing Science Research, http://www.cse.dmu.ac.uk/%7Erij/newrep/newrep.html
[10] Eminov, Mubariz, Querying a Database by Fuzzification of Attribute Values.
[11] Wang, Li-Juan & Wang, Xi-Zhao & Ha, Ming-Hu & Yin-Shan, Mining the Weights of
Similarity Measure Through Learning.
28. [12] Tashiro, H. & Ohki, N. & Yokoyama, T. & Matsushita, Y., Managing Subjective
Information in Fuzzy Database Systems, 156 – 161.
[13] Baklarz, George, Using Neural Nets to Optimize Retrieval in a Fuzzy Relational Database,
191 – 200.
[14] Bilgic, Taner & Turksen, I.B, Measurement of membership functions: Theoretical and
Empirical work, 17 – 21.
[15] Chameau, J. L. & Santamarina, J. C. (1987a), Membership Part I: Comparing Methods of
Measurement, 287-301.
29. Appendix A
Stored Procedures
A. Fetch_All_Images
/* Database Research Spring 2005
Shweta Sanghi
Fetch_All_Images, stored procedure, fetches all images from the database for training */
CREATE PROCEDURE [Fetch_All_Images]
AS
SET ANSI_NULLS ON
exec('select * from Person P')
GO
B. Fetch_Data
/* Database Research Spring 2005
Shweta Sanghi
Fetch_Data, stored procedure, is used to fetch the data from the database based on old method
of assigning weights. It interprets the fuzzy modifiers and translates them into SQL Queries for
our database */
CREATE PROCEDURE [Fetch_Data]
@query as varchar(10),
@s1 as varchar(50),
@s2 as varchar(50)
AS
SET ANSI_NULLS ON
declare @f_query as varchar(500),
@high as float,@low as float
print @high
if @s2 = 'Blue' or
@s2='Green' or
@s2='Brown'
begin
30. select @high =high from Range where modifier=@s1
select @low= low from Range where modifier=@s1
print @s2
exec('select * from Person P,Color C where
P.ID=C.ID and C.weight <= '+@high+' and C.weight >= '+@low+' and
C.Color='+'"'+@s2+'"')
end
if @s2 = 'Broad' or
@s2 = 'Average' or
@s2='Narrow'
begin
select @high = high from Range where modifier=@s1
select @low =low from Range where modifier=@s1
exec('select * from Person P,Face F where
P.ID=F.ID and F.weight >= '+@low+' and F.weight <= '+@high+' and
F.Face='+'"'+@s2+'"')
end
GO
C. Fetch_Direct_Data
/* Database Research Spring 2005
Shweta Sanghi
Fetch_Direct_Data, stored procedure, is used to fetch the data from the database based on
direct rating method of assigning weights. It interprets the fuzzy modifiers and translates them
into SQL Queries for our database */
CREATE PROCEDURE [Fetch_Direct_Data]
@query as varchar(10),
@s1 as varchar(50),
@s2 as varchar(50)
AS
SET ANSI_NULLS ON
declare @f_query as varchar(500),
@high as float,@low as float
print @high
if @s2 = 'Blue' or
@s2='Green' or
@s2='Brown'
31. begin
select @high =high from Range where modifier=@s1
select @low= low from Range where modifier=@s1
print @s2
exec('select * from Person P,ColorDirect C where
P.ID=C.ID and C.weight <= '+@high+' and C.weight >= '+@low+' and
C.Color='+'"'+@s2+'"')
end
if @s2 = 'Broad' or
@s2 = 'Average' or
@s2='Narrow'
begin
select @high = high from Range where modifier=@s1
select @low =low from Range where modifier=@s1
exec('select * from Person P,Face F where
P.ID=F.ID and F.weight >= '+@low+' and F.weight <= '+@high+' and
F.Face='+'"'+@s2+'"')
end
GO
D. initialize_weights
/* Database Research Spring 2005
Karen Joy and Smita Dattatri
Updated by Shweta Sanghi
This procedure is used to initialize the weights associated with the “Eye Color” and the “Face
Width “ attributes. This procedures assigns a random weight to each of the entries in the “Color”
and the “ Face” table. We have used a cursor that loops through each record in the “Face” and
the “Color” table and assigns a random value to the corresponding weights in each row. This
procedure is not invoked via the application .It is executed directly on the database to initialize
the weights.*/
CREATE PROCEDURE [initialize_weights]
as
declare @id as int,@color as varchar(20),@face as varchar(20)
DECLARE color_weight CURSOR
for
select ID,color from color
OPEN color_weight
FETCH NEXT FROM color_weight
into @ID,@color
32. WHILE @@FETCH_STATUS = 0
BEGIN
print 'ID'
print @id
print 'color'
print @color
update color
set weight=rand()
where ID=@id and color=@color
FETCH NEXT FROM color_weight
into @ID,@color
END
CLOSE color_weight
DEALLOCATE color_weight
DECLARE face_weight CURSOR
for
select ID,face from face
OPEN face_weight
FETCH NEXT FROM face_weight
into @ID,@face
WHILE @@FETCH_STATUS = 0
BEGIN
print 'ID+Face'
print @id
print 'Face'
print @face
update Face
set weight=rand()
where ID=@id and Face=@face
FETCH NEXT FROM face_weight
into @ID,@face
END
CLOSE face_weight
DEALLOCATE face_weight
GO
33. E. Insert_Test_Data
/* Database Research Spring 2005
Shweta Sanghi
Insert_Test_Data, stored procedure, is used to insert the user’s satisfaction information for
direct rating method into Test table*/
CREATE PROCEDURE .[Insert_Test_Data]
@ID as int,
@ValueBlue as int,
@TypeBlue as varchar(50)
AS
SET ANSI_NULLS ON
if @TypeBlue = 'very'
begin
insert into Test (ID,VeryBlue) values(@ID,@ValueBlue)
end
else
begin
if @TypeBlue = 'medium'
begin
insert into Test (ID,MediumBlue) values(@ID,@ValueBlue)
end
else
begin
if @TypeBlue = 'less'
begin
insert into Test (ID,LessBlue) values(@ID,@ValueBlue)
end
end
end
GO
34. F. Insert_TestOld_Data
/* Database Research Spring 2005
Shweta Sanghi
Insert_TestOld_Data, stored procedure, is used to insert the user’s satisfaction information for
previous prototype method into TestOld table*/
CREATE PROCEDURE .[Insert_TestOld_Data]
@ID as int,
@ValueBlue as int,
@TypeBlue as varchar(50)
AS
SET ANSI_NULLS ON
if @TypeBlue = 'very'
begin
insert into TestOld (ID,VeryBlue) values(@ID,@ValueBlue)
end
else
begin
if @TypeBlue = 'medium'
begin
insert into TestOld (ID,MediumBlue) values(@ID,@ValueBlue)
end
else
begin
if @TypeBlue = 'less'
begin
insert into TestOld (ID,LessBlue) values(@ID,@ValueBlue)
end
end
end
GO
35. G. Insert_Train_Data
/* Database Research Spring 2005
Shweta Sanghi
Insert_Train_Data, stored procedure, is used to insert the user’s view for blue eye color of
image.*/
CREATE PROCEDURE .[Insert_Train_Data]
@ID as int,
@TrainBlue as int
AS
SET ANSI_NULLS ON
insert into Train (ID,TrainBlue) values(@ID,@TrainBlue)
GO
H. Update_Data
/* Database Research Spring 2005
Karen Joy and Smita Dattatri
Updated by Shweta Sanghi
This procedure is used to fetch the data from the database. It interprets the fuzzy modifiers and
translates them into SQL Queries for our database.*/
CREATE PROCEDURE [Update_Data]
@ID as int,
@color as varchar(50),
@more_less as varchar(50),
@modifier as varchar(50)
AS
SET ANSI_NULLS ON
declare @threshold as float,@existing_weight as float,@new_weight as float
if @color = 'Blue' or
@color='Green' or
@color='Brown'
begin
select @threshold =threshold from Range where modifier=@modifier
select @existing_weight=Weight from Color where ID=@ID and Color=@color
set @new_weight=@existing_weight
36. if @more_less = 'meets'
begin
if @existing_weight < @threshold
begin
set @new_weight = @existing_weight + .01
end
if @existing_weight > @threshold
begin
set @new_weight = @existing_weight - .01
end
end
else
begin
if @more_less = 'more'
begin
if @modifier = 'very'
begin
if @existing_weight > @threshold
begin
set @new_weight = @existing_weight - .01
end
if @existing_weight < @threshold
begin
set @new_weight = @existing_weight + .01
end
end
else
begin
set @new_weight = @existing_weight + .01
end
end
else
begin
if @modifier='slightly'
begin
if @existing_weight > @threshold
begin
set @new_weight = @existing_weight - .01
end
if @existing_weight < @threshold
begin
set @new_weight = @existing_weight + .01
end
end
else
37. begin
set @new_weight = @existing_weight - .01
end
end
end
update Color set weight=@new_weight where ID=@ID and color=@color
end
if @color = 'Broad' or
@color = 'Average' or
@color='Narrow'
begin
select @threshold =threshold from Range where modifier=@modifier
select @existing_weight=Weight from Face where ID=@ID and Face=@color
set @new_weight=@existing_weight
if @more_less = 'meets'
begin
if @existing_weight < @threshold
begin
set @new_weight = @existing_weight + .01
end
if @existing_weight > @threshold
begin
set @new_weight = @existing_weight - .01
end
end
else
begin
if @more_less = 'more'
begin
if @modifier = 'very'
begin
if @existing_weight > @threshold
begin
set @new_weight = @existing_weight - .01
end
if @existing_weight < @threshold
begin
set @new_weight = @existing_weight + .01
end
end
else
begin
set @new_weight = @existing_weight + .01
38. end
end
else
begin
if @modifier='slightly'
begin
if @existing_weight > @threshold
begin
set @new_weight = @existing_weight - .01
end
if @existing_weight < @threshold
begin
set @new_weight = @existing_weight + .01
end
end
else
begin
set @new_weight = @existing_weight - .01
end
end
end
update Face set weight=@new_weight where ID=@ID and Face=@color
end
GO
39. Appendix B
Source Code
Source Code for Direct Rating Method
'Database Research Spring 2005
'Shweta
'This form takes user id as input and invokes the stored procedure
"Fetch_All_Images"
'which queries the database to retrieve all images with slide bar for user
input.
'If the user presses the update button then user’s input is stored into the
database
'by the stored procedure called “Insert_Train_Data”.
Imports System.IO
Imports System.Data.SqlClient
Public Class learn
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Button3 As System.Windows.Forms.Button
40. Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Button3 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Panel1 = New System.Windows.Forms.Panel
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button3
'
Me.Button3.Font = New System.Drawing.Font("Verdana", 9.75!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button3.Location = New System.Drawing.Point(560, 640)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(88, 23)
Me.Button3.TabIndex = 0
Me.Button3.Text = " Cancel"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label1.Location = New System.Drawing.Point(280, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(616, 23)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Panel1
'
Me.Panel1.Location = New System.Drawing.Point(0, 32)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(864, 600)
Me.Panel1.TabIndex = 2
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 9.75!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(176, 640)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(104, 23)
Me.Button1.TabIndex = 3
Me.Button1.Text = "More"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Verdana", 9.75!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button2.Location = New System.Drawing.Point(352, 640)
41. Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(120, 23)
Me.Button2.TabIndex = 4
Me.Button2.Text = "Update"
'
'learn
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(872, 669)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button3)
Me.Name = "learn"
Me.Text = "Training Images "
Me.ResumeLayout(False)
End Sub
#End Region
'user defined variables
Dim User As New Integer 'variable storing user id
Dim ds As New DataSet 'varibale storing dataset which is the result of
the query
Dim al As New ArrayList 'varibale storing image set which has image and
slide bar
Dim nextPix As Integer 'variable indicating the first picture to be
displayed on a page
Dim remainingPix As Integer 'variable indicating the remaining pictures
to be displayed on a page
'Connection String used to connect to the database.
'vikas=Name Of the Computer
'DBResearch=Name of the database
Dim con As New System.Data.SqlClient.SqlConnection("data
source=vikas;initial catalog=DBResearch;user
id=dbresearch;password=dbresearch")
'Procedure takes user id from main form and assigns to variable called
User
'Public Sub initialize(ByVal s1 As Integer)
' User = s1
'End Sub*/
'Event handling for cancel button. It closes the database connection and
exit the project
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
con.Close()
Me.Dispose()
Me.Close()
End
End Sub
' This function is invoked when the form is loaded.The stored procedure
"Fetch_All_Images" is
42. 'invoked. This stored procedure executes the query and returns the result
set
Private Sub learn_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim I As Integer
Dim Count As Integer
'Making connection to database and executes the stored procedure
called "Fetch_All_Images"
'and put the dataset in da variable
Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_All_Images",
con)
cmd.CommandType = CommandType.StoredProcedure
Try
Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd)
da.Fill(ds)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
'displays the number of rows returned as a result of query (use for
debugging)
'MessageBox.Show(ds.Tables(0).Rows().Count)
'This block executes the each dataset row, creates image set
' and displays on the form
If (ds.Tables(0).Rows().Count) > 0 Then
Count = ds.Tables(0).Compute("COUNT(ID)", "")
'The following block of code creates a new object of ImageSet for
each
'record in the which result set which contains the image and the
slide bar
'associated with it. It also reads the image in binary format
from the database
'and displays it appropriately.
For I = 0 To Count - 1
Dim S As New ImageSet
Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2),
Byte())
Dim memorybits As New MemoryStream(bits)
Dim bitmap As New Bitmap(memorybits)
S.picture.Image = bitmap
al.Add(S)
al(I).ID = ds.Tables(0).Rows(I).Item(0)
Next I
'variable indicating the first picture to be displayed on a page
nextPix = 0
'variable indicating the remaining pictures to be displayed
remainingPix = al.Count
43. 'The following block of code places the components on the Group
Box and
'then places the group box on the panel to be displayed.
placeComponents(nextPix)
'This procedure is evoked so that update button is disabled
'until form displays last page of the query. At the last page,
more button is disabled
updateButtons()
'label on the Panel.
Label1.Text() = "Please Answer the following question."
Else
MessageBox.Show("No images match your criteria")
End If
End Sub
'The following block of code places the components on the Group Box and
'then places the group box on the panel to be displayed.
Private Sub placeComponents(ByVal Position1 As Integer)
Dim X As Integer, Y As Integer
Y = 8
Dim I As Integer
'limit the display to 6 images
Dim lastPix As Integer
'determing the last picture for the current page
If remainingPix <= 6 Then
lastPix = Position1 + remainingPix - 1
Else : lastPix = Position1 + 5
End If
For I = Position1 To lastPix
Dim G As New GroupBox
G.Location() = New Point(8 + X, Y)
G.Size() = New Size(268, 295) 'was (288,350)
al(I).picture.Location = New Point(50, 24)
al(I).picture.size = New Size(200, 200) 'was (224,120)
al(I).label_response.location = New Point(50, 230) 'was (32, 250)
al(I).label_response.size = New Size(176, 24)
al(I).user_response.size = New Size(200, 24)
al(I).user_response.location = New Point(50, 260) 'was (32, 275)
G.Controls.Add(al(I).picture)
G.Controls.Add(al(I).user_response)
G.Controls.Add(al(I).label_response)
Panel1.Controls.Add(G)
'Allows to display multiple rows of records.
X = 300 + X
If ((I Mod 6) = 2) Then
Y = 295 + 5 + Y
44. X = 0
End If
Next
'update the number of picutes left to be displayed
If remainingPix > 6 Then
remainingPix = remainingPix - 6
Else
remainingPix = 0
End If
'update first picture on next page
nextPix = nextPix + 6
End Sub
'set up buttons depending on number of images in query result
'This procedure is evoked so that update button is disabled
'until form displays last page of the query. At the last page, more
button is disabled
Private Sub updateButtons()
If al.Count <= 6 Or remainingPix = 0 Then
Me.Button1.Enabled = False
Me.Button2.Enabled = True
Else
Me.Button1.Enabled = True
Me.Button2.Enabled = False
End If
End Sub
'----------------------------------------------------------------
'The class ImagesSet is a user defined class which has the image
'and the slide bar as its components.
Public Class ImageSet
Public picture As PictureBox
Public user_response As HScrollBar
Public label_response As Label
Public ID As Integer
Public Sub New()
picture = New PictureBox
user_response = New HScrollBar
label_response = New Label
label_response.Text = "How blue are the eyes?"
label_response.Font = New System.Drawing.Font("Verdana", 8,
FontStyle.Bold)
user_response.Minimum = 0
user_response.Maximum = 109
ID = 0
End Sub
End Class
'Event Handling for More Button. It clears the panel,
'builds and displays next page
45. 'set up buttons depending on number of images in query result
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'clear existing pictures
Panel1.Controls.Clear()
'build and display next page
placeComponents(nextPix)
Panel1.Show()
'set up buttons depending on number of images in query result
updateButtons()
End Sub
'Event Handling for update button. It evokes the stored produce called
"Insert_Train_Data"
'to insert into database the users's response
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim I As Integer
' Dim UserId As Integer
Dim TrainBlue As Integer
' UserId = User
'con.Open()
'This block of code records the value of slide bar movement by the
user in
'order to update the corresponding rows in the database.For each
person the
'stored procedure Update_Data is invoked.
For I = 0 To al.Count - 1
TrainBlue = al(I).User_Response.value
Dim daptr = New SqlDataAdapter
daptr.SelectCommand = New SqlCommand
daptr.SelectCommand.CommandType = CommandType.StoredProcedure
daptr.SelectCommand.CommandText = "dbo.Insert_Train_Data"
daptr.SelectCommand.Connection = con
'daptr.SelectCommand.Parameters.Add("@UserID", UserId)
daptr.SelectCommand.Parameters.Add("@ID", al(I).ID)
daptr.SelectCommand.Parameters.Add("@TrainBlue", TrainBlue)
con.Open()
Try
daptr.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Failed to execute query")
End Try
con.Close()
Next
Dim MessageLearn As MessageLearn
MessageLearn = New MessageLearn
Me.Dispose()
MessageLearn.Show()
End Sub
End Class
'Database Research Spring 2005
46. 'Shweta Sanghi
'Main form is the start up form of the project. This forms asks the user
whether he wants to provide
'training samples needed to elicit membership function or wants to provide
feedback.
'If he wants to train then the learn form is evoked otherwise query form is
evoked
'Also it passes used id which is input by the user to learn form or query
form
Public Class main
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
47. '
'RadioButton1
'
Me.RadioButton1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.RadioButton1.Location = New System.Drawing.Point(264, 160)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.TabIndex = 2
Me.RadioButton1.Text = "Train "
Me.RadioButton1.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'RadioButton2
'
Me.RadioButton2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.RadioButton2.Location = New System.Drawing.Point(264, 224)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 3
Me.RadioButton2.Text = "Test"
Me.RadioButton2.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(104, 320)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(160, 32)
Me.Button1.TabIndex = 4
Me.Button1.Text = "Ok"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button2.Location = New System.Drawing.Point(456, 320)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(144, 32)
Me.Button2.TabIndex = 5
Me.Button2.Text = "Cancel"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label2.Location = New System.Drawing.Point(136, 96)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(384, 23)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Choose operation that you would like to do"
'
'Label1
48. '
Me.Label1.Font = New System.Drawing.Font("Verdana", 14.0!,
System.Drawing.FontStyle.Bold)
Me.Label1.Location = New System.Drawing.Point(24, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(656, 32)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Welcome to Fuzzy Relational Database for Images
Retrieval"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'main
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(704, 373)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Controls.Add(Me.Label1)
Me.Name = "main"
Me.Text = "Fuzzy Relational Database"
Me.ResumeLayout(False)
End Sub
#End Region
'Event handling procedure for cancel button to exit from the project
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Me.Dispose()
Me.Close()
End
End Sub
'Event handling procedure for ok button. According to the user’s
response,
'either query form is evoked or learn form is evoked having user id as
input
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If (RadioButton1.Checked() = True) Then
Dim f As learn
f = New learn
Me.Hide()
f.Show()
ElseIf (RadioButton2.Checked() = True) Then
Dim f As TestslightlyBlue
f = New TestslightlyBlue
f.initialize()
Me.Hide()
f.Show()
Else
MessageBox.Show("Please choose operation or press cancel button.")
End If
49. End Sub
End Class
Database Research Spring 2005
'Shweta Sanghi
'This form informs the user that the update opearation was successful and
asks the user
' whether he/she would like to run another train.
Public Class MessageLearn
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
50. Me.Label1.Location = New System.Drawing.Point(88, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(312, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Thanks for your help in research"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label2.Location = New System.Drawing.Point(128, 64)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(216, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Please Press Next Button"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(112, 112)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 32)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Next"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button2.Location = New System.Drawing.Point(288, 112)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(80, 32)
Me.Button2.TabIndex = 3
Me.Button2.Text = "End"
'
'MessageLearn
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(488, 173)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Location = New System.Drawing.Point(5000, 7000)
Me.Name = "MessageLearn"
Me.Text = "Message"
Me.ResumeLayout(False)
End Sub
#End Region
'Event handling for yes button. It displays the learn form
51. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f As learn
f = New learn
f.Show()
Me.Dispose()
End Sub
'Event handling for No button to exit the project
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Me.Dispose()
Me.Close()
End
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click
End Sub
End Class
'Database Research Spring 2005
'Shweta Sanghi
'This form informs the user that the update opearation was successful and
asks the user
' whether he/she would like to run another test.
Public Class MessageTest
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
52. 'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label1.Location = New System.Drawing.Point(88, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(312, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Thanks for your help in research"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label2.Location = New System.Drawing.Point(120, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(216, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Please Press Next Button"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(112, 112)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 32)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Next"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button2.Location = New System.Drawing.Point(288, 112)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(80, 32)
Me.Button2.TabIndex = 3
53. Me.Button2.Text = "End"
'
'MessageTest
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(488, 173)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Location = New System.Drawing.Point(5000, 7000)
Me.Name = "MessageTest"
Me.Text = "Message"
Me.ResumeLayout(False)
End Sub
#End Region
'Event handling for yes button. It displays the Form1 form for testing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f As TestslightlyBlue
f = New TestslightlyBlue
f.initialize()
f.Show()
Me.Dispose()
End Sub
'Event handling for No button to exit the project
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Me.Dispose()
Me.Close()
End
End Sub
End Class
‘Database Research Summer 2004
'Karen Joy and Smita Dattatri
'Database Research Spring 2005
'Updated by Shweta Sanghi
'This form reads the file which contains the Fuzzy Query and displays that on
the screen
'giving the user a chance to change the query.The user can then click on the
"Submit" button which submits the
'fuzzy query to the intermediate layer(stored procedures)in order to be
processed.
Imports System.io
Public Class QueryForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
54. MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.TextBox1.Location = New System.Drawing.Point(40, 40)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.TextBox1.Size = New System.Drawing.Size(512, 50)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox1"
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("Verdana", 9.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.TextBox2.Location = New System.Drawing.Point(40, 136)
Me.TextBox2.Multiline = True
55. Me.TextBox2.Name = "TextBox2"
Me.TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.TextBox2.Size = New System.Drawing.Size(512, 50)
Me.TextBox2.TabIndex = 1
Me.TextBox2.Text = "TextBox2"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 9.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(104, 256)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(136, 40)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Submit Query"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Verdana", 9.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button2.Location = New System.Drawing.Point(304, 256)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(136, 40)
Me.Button2.TabIndex = 3
Me.Button2.Text = "Cancel"
'
'QueryForm
'
Me.AcceptButton = Me.Button1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(592, 366)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Name = "QueryForm"
Me.Text = "Query"
Me.ResumeLayout(False)
End Sub
#End Region
'user defined variables
Dim User As Integer 'variable storing user id
Dim modifier As String 'varibale storing values such as slightly,
medium, very
Dim color_face As String 'variable storing values such as Blue, Brown,
Green, blue, green, brown, broad, narrow
Dim strarry(20) As String
'This function is invoked when the form is loaded.
'It reads the input file called input.txt which contains the Fuzzy Query
'It also reads the input file called input1.txt to read the modifiers
56. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Reads the file which contains the Fuzzy Query
Dim myfileStream As New IO.FileStream("C:input.txt",
IO.FileMode.Open, IO.FileAccess.Read)
Dim myreader As New IO.StreamReader(myfileStream)
Try
TextBox1.Clear()
Dim line2 As New String("")
Do
line2 = line2 + myreader.ReadLine + vbCrLf
Loop Until myreader.Peek = -1
TextBox1.AppendText(line2)
Catch ex As Exception
TextBox1.AppendText("File is empty")
Finally
myreader.Close()
End Try
Dim myfileStream1 As New IO.FileStream("C:input1.txt",
IO.FileMode.Open, IO.FileAccess.Read)
Dim myreader1 As New IO.StreamReader(myfileStream1)
Try
TextBox2.Clear()
Dim line1 As New String("")
Dim i As Integer
i = 0
Do
'line1 = line1 + myreader1.ReadLine + vbCrLf
strarry(i) = New String(myreader1.ReadLine())
i = i + 1
Loop Until myreader1.Peek = -1
TextBox2.AppendText(strarry(0) + vbCrLf + strarry(1))
Catch ex As Exception
' TextBox2.AppendText("File is empty")
TextBox2.AppendText(ex.ToString)
Finally
myreader1.Close()
End Try
End Sub
'Procedure takes input from main form and assigns user id to variable
called User
'Public Sub initialize(ByVal us1 As Integer)
' User = us1
'End Sub
'Event handling for Submit button. It evokes and initializes the Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f As TestVeryBlue
f = New TestVeryBlue
Dim s1 As String = TextBox2.Lines(0)
Dim s2 As String = TextBox2.Lines(1)
'f.initialize(TextBox1.Text, s1, s2)
Me.Hide()
f.Show()
End Sub
57. 'Event handling procedure for cancel button to exit the project
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Me.Dispose()
Me.Close()
End
End Sub
End Class
‘Database Research Summer 2004
'Karen Joy and Smita Dattatri
'Database Research Spring 2005
'Updated by Shweta Sanghi
'This form invokes the stored procedure "Fetch Data" which interprets the
Fuzzy query and
'returns the set of rows to be displayed on the User Interface.This form also
invokes a
'stored procedure called "Insert_Test_data" which updates the database
depending on the feedback
'given by the user.
Imports System.IO
Imports System.Data.SqlClient
Public Class TestMediumBlue
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
58. 'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Panel2 As System.Windows.Forms.Panel
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.Button3 = New System.Windows.Forms.Button
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Panel2 = New System.Windows.Forms.Panel
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Button3)
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.Button2)
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom
Me.Panel1.Location = New System.Drawing.Point(0, 637)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(872, 32)
Me.Panel1.TabIndex = 2
'
'Button3
'
Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom
Me.Button3.Location = New System.Drawing.Point(216, 0)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(104, 24)
Me.Button3.TabIndex = 4
Me.Button3.Text = "More"
'
'Button1
'
Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom
Me.Button1.BackColor = System.Drawing.Color.LightGray
Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(384, 0)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(104, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Update"
'
'Button2
'
Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom
Me.Button2.BackColor = System.Drawing.Color.LightGray
59. Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button2.Location = New System.Drawing.Point(552, 0)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(104, 24)
Me.Button2.TabIndex = 3
Me.Button2.Text = "Cancel"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label1.Location = New System.Drawing.Point(280, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(552, 24)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Label1"
'
'Panel2
'
Me.Panel2.Location = New System.Drawing.Point(0, 32)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(864, 600)
Me.Panel2.TabIndex = 5
'
'TestMediumBlue
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(872, 669)
Me.Controls.Add(Me.Panel2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Panel1)
Me.Name = "TestMediumBlue"
Me.Text = "Testing Direct Method"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
'user defined variables
Dim User As Integer 'variable storing user id
Dim Query As String 'variable storing the query
Dim modifier As String 'varibale storing values such as slightly,
medium, very
Dim color_face As String 'variable storing values such as Blue, Brown,
Green, blue, green, brown, broad, narrow
Dim ds As New DataSet 'varibale storing dataset which is the result
of the query
Dim al As New ArrayList 'varibale storing image set which has image
and check boxes
Dim nextPix As Integer 'variable indicating the first picture to be
displayed on a page
60. Dim remainingPix As Integer 'variable indicating the remaining pictures
to be displayed on a page
'Connection String used to connect to the database.
'vikas=Name Of the Computer
'DBResearch=Name of the database
Dim con As New System.Data.SqlClient.SqlConnection("data
source=vikas;initial catalog=DBResearch;user
id=dbresearch;password=dbresearch")
'Event handling procedure for the 'Update' button . It evokes the stored
produce called "Insert_Test_Data"
'to insert into database the users's response
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim I As Integer
' Dim UserId As Integer
Dim TestBlue As Integer
'UserId = User
'con.Open()
'This block of code checks which check boxes were clicked by the user
and for which
'person in order to update the corresponding rows in the database.For
each person the
'stored procedure Insert_Test_Data is invoked.
For I = 0 To al.Count - 1
If (al(I).meets_criteria.Checked() = True) Then
TestBlue = 0
ElseIf (al(I).no_criteria_meet.Checked() = True) Then
TestBlue = 1
End If
Dim daptr = New SqlDataAdapter
daptr.SelectCommand = New SqlCommand
daptr.SelectCommand.CommandType = CommandType.StoredProcedure
daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data"
daptr.SelectCommand.Connection = con
'daptr.SelectCommand.Parameters.Add("@UserID", UserId)
daptr.SelectCommand.Parameters.Add("@ID", al(I).ID)
daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue)
daptr.SelectCommand.Parameters.Add("@TypeBlue", "medium")
con.Open()
Try
daptr.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Failed to execute query")
End Try
con.Close()
Next
Dim TestVeryBlue As TestVeryBlue