Hi!
I have datum which contains m values (v1, v2, ..., vm) and I would like get a sorted list of such data so that it is sorted by similarity to some given datum k with values (k1, k2, ..., km). Similarity means in this case how many values are the same. Some datum is more similar to the k than some other one if it has more equal values (v1==k1, v2==k2, ... pairs) that the other one.
I made a table Data with (DataID, ValueID, Value) and try this select query to get a list compared to the first datum:
SELECT Data1.DataID, COUNT(*) AS C FROM Data AS Data1, Data AS Data2 WHERE Data2.DataID=0 AND Data2.ValueID=Data1.ValueID AND Data2.Value=Data1.Value GROUP BY Data1.DataID ORDER BY C DESC;
But it is really slow for large data sets.
Is there some better way to store this data into MySQL database and than retrive sorted list?
Mike
I have datum which contains m values (v1, v2, ..., vm) and I would like get a sorted list of such data so that it is sorted by similarity to some given datum k with values (k1, k2, ..., km). Similarity means in this case how many values are the same. Some datum is more similar to the k than some other one if it has more equal values (v1==k1, v2==k2, ... pairs) that the other one.
I made a table Data with (DataID, ValueID, Value) and try this select query to get a list compared to the first datum:
SELECT Data1.DataID, COUNT(*) AS C FROM Data AS Data1, Data AS Data2 WHERE Data2.DataID=0 AND Data2.ValueID=Data1.ValueID AND Data2.Value=Data1.Value GROUP BY Data1.DataID ORDER BY C DESC;
But it is really slow for large data sets.
Is there some better way to store this data into MySQL database and than retrive sorted list?
Mike