I tried a search, but wasn't able to find anything. Mind you, I may have been searching the wrong thing.
So, my question is with regard to join tables in Rails.
I plan to have Users and Books and a join table Favourites that would link Users to Books.
So, my initial thought is that the Favourites table would have user_id and book_id.
However, I want to also provide suggestions. So, if user1 likes books 1,2,3,4 and user2 likes books 1,2,3,4,5; I want to be able to suggest book 5 to user1.
I am thinking that having a table with user_id and then an array containing their favourite books would be easiest for figuring out appropriate suggestions.
So, my question is two fold. First, do I need two tables? One join table and another for the table with array? Or can/should those two be the same? Second, is this the best way to set all this up? I am self-taught, so I very well could be missing something very basic..
The help is much appreciated!
To answer your first question: you're looking for a single, standard join table. Including another table (or another column) with a different representation of the same information will prove difficult for you to keep consistent and probably won't help you as much as you think.
Reason being the answer to question two: there are a lot of really great recommendation engines out here that will do all this work for you!
The biggest one is recommendify but it hasn't been active for about a year. I used it in a project and found it very satisfying: it's fast and the results, in my experience, seem to be accurate.
Recommendable is much more recently updated but also works more on upvotes and downvotes. Still, you can treat a "favorite" of a product as an upvote and probably use it like that if you wanted to.
If neither of those fit your needs, you can check out RubyToolbox's list of recommendation engines.