I'm working on a project that will use a comparison voting logic to sort the highest rated to the top and lowest to the bottom(Similar to a "hot or not" or "Hotstagram"). Basically what I need to do is take 2 random pictures that are directly next to each other in the database and have users vote, adding one point to the winner and subtracting on point from the loser essentially filtering the highest to the top.
My question is two fold, How can I get a random item in a MySql database then get a random item directly next to it. and secondly (if anyone has prior experience with this) how would you structure your DB? I'm thinking One table for images and a second that will hold the votes(then compile the results on page load). I guess what my concern is here, for the ranking, ever new entered photo will start at zero, so you could have X amount of photos with the same rank? I'm just throwing some thoughts out there and I need another mind to toss this around.