views:

38

answers:

1

Let's assume I have a table full of teachers.

every teacher has these parameters:

Experience
Hourly Cost
Distance
Last Login
Total Rating (like an eBay score given by student)

the fact is, that I would avoid to give my users those dropdown menus to choose the sorting option, but i would build a search engine smart enough to compute the best match

for best match i mean a good balance of each parameter, so the first results are the teachers who have a recent login, who are closer to you etc...but not necesserely alwasy with the same sorting sequence (login DESC, THEN distance ASc etc...)

example: i set as first parameter of sorting the lastlogin DESC. how to avoid that a teacher (with alow score and faraway from me) that Sign in every day is going to be always first in my results, and maybe a teacher that is only 1mile form me, but he sign in only once a week is going to be penalized for that...

i hope i was clear.. ;)

+2  A: 

You can build an estimate function to calculate the relevance from all that parameter, with specific weight for each. Then sort on the result.

Mostfavorite(teacher) = A(teacher.Experience) + B(teacher.HourlyCost) + C(teacher.Distance) + D(teacher.LastLogin) + E(teacher.TotalRating)
pinichi
that's interesting but unfortunately my math knowledge is limited, and i forgot all i've studied about statistic fomulas etc...where can i find some examples? thanks
camelCase
Simpler: Mostfavorite(teacher) = a* Experience + b*HourlyCost + c *Last Login...<b> and you can choose appropriate a, b as you like. Ex: you think the Last login is important then increase c.
pinichi
ok, but talking about a mysql query, how can you multiple a const value for the last_login (a timestamp)?
camelCase
basically my question at this point is how to integrate your formula in a MYSQL query...
camelCase
You can define a function, I think MySQL allow this, and use in your query. `SELECT favourt(Experien, HourlyCost) as Fav FROM ORDER BY Fav`. Or you can add a Favour column alfer Experience, HourlyCost,... in TeacherInfo table, and set value when INSERT or UPDATE into this table.
pinichi
Some info about Evaluation function:http://en.wikipedia.org/wiki/Evaluation_function
pinichi