databasealgorithmmatchbest-fit

Data search with partially match


I have a database with column A,B,C and row data, for example:

A         B         C 
test1    2.0123    3.0123
test2    2.1234    3.1234

In my program I would like to search for the bestfit match in the databases, for example I will key in value b=2.133, c=3.1342, then it will return me test2, how can I do that?

Please give me some idea or keyword to google as what I was thinking is searching algorithm but seem like searching algorithm are more on completely match and is not find the bestfit match. Or is this binpacking algorithm? How can I solve the problem with that.

I got about 5 column B,C,D,E,F and find the most match value.


Solution

  • Seems like you are looking for a k-d tree that maps 2-dimensional space (attributes B,C that are the key) to a value (attribute A).

    K-D tree allows efficient look up for nearest neighbor of a given query, which seems to be exactly what you are after.

    Note that the same DS will efficiently handle more attributes if needed, by increasing the dimensionality of the key.