Reputation: 1546
i'm writing a kind of 'dating service' website (just for fun & practice).
But right now i'm stuck. I use PHP and MySQL.
Every new member must complete 'What do you like (to do)?' question separated by commas:
Like this:
computing, dancing, reading, TV, movies
and so on.
My question is 'how can i show recommended people to someone'?
i.e.
MEMBER A:
computing, dancing, reading, TV, movies
MEMBER B:
books, cellphones, rugby
MEMBER C:
dancing, movies
In this scenario, A & C have more chances to get along than A & B or B & C
I'll appreciate any hint to try to do this real, or your own ideas to solve this. Thanks!
PS: Sorry about my english
Upvotes: 1
Views: 125
Reputation: 17314
I would say that step one is to split their list of interests into separate words. Then make a table with only two columns: user and interest.
| user | interest |
|------|-----------|
| A | computing |
| A | dancing |
| ... | ....... |
| C | movies |
and so on. Then all you need to do is join the table with itself and count the number of interests in common with the target user. Group by user, and sort by the count of interests in common (assuming that's your metric for how well they will get along). I can't think of the sql for this right off the top of my head, but maybe it's a good exercise for you. Or maybe someone else will post it as an answer. Good luck!
Upvotes: 2
Reputation: 93
Well, you could start by counting how many interests each member have in common, and then you just select the one that has the most in common. I am pretty sure that you could do this with just a SQl Query, or maybe 2... Well, of course, depending on your database structure.
You would need to post the database structure you are using, so me and others and actually give you some code...
Upvotes: 1