Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare data by similarity

Status
Not open for further replies.

mimics

Programmer
Jun 22, 2003
13
SI
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top