keldorn Posted December 20, 2009 Share Posted December 20, 2009 I'm building an application, I wanted to add the ability of the user to favorite stuff. What is good way to go about storing the favorite data? I'm thinking here, making a table for each user is not a good idea, I really trying think how sites like Youtube do this without scaling issues, would you save all their favorites in an Array and serialize it in the 1 row along with their username? Then when you need just unserislize and it and iterate over it, Is that how places like Youtube does it? or create 1 big table dump for all favorite of everybody and just have it sorted from userid=>user recursion? Like id + user_id + favorite_id THen just do SELECT favorite_id FROM favorites where user_id=$userid Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/ Share on other sites More sharing options...
Daniel0 Posted December 20, 2009 Share Posted December 20, 2009 I'd just have a table called favorites with two fields: user_id and stuff_id. Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/#findComment-980855 Share on other sites More sharing options...
keldorn Posted December 20, 2009 Author Share Posted December 20, 2009 I'd just have a table called favorites with two fields: user_id and stuff_id. So you think that would scale? I wonder how say Youtube handles it, imagine they million of users, with each say 100 favorites, that would be potntional hundreds of millions of row in a table. I dont see it working. Maby on a small scale. Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/#findComment-980856 Share on other sites More sharing options...
Daniel0 Posted December 20, 2009 Share Posted December 20, 2009 Databases are build to handle large amounts of data. This will also use less space than your proposed serialization method. Having a lot of data in a database is generally not a problem. Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/#findComment-980857 Share on other sites More sharing options...
keldorn Posted December 20, 2009 Author Share Posted December 20, 2009 Ok, I'll just take that route, serialization doesn't sound like my cup of tea anyways. Thanks. I probably likely wont have scaling issues the size of Youtube, but it is always good to design your application right from the start with scaling in mind. Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/#findComment-980858 Share on other sites More sharing options...
Daniel0 Posted December 20, 2009 Share Posted December 20, 2009 Well, if you're running YouTube you'd also have load balancers and dedicated database boxes with lots of memory and fast disk I/O. Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/#findComment-980860 Share on other sites More sharing options...
keldorn Posted December 20, 2009 Author Share Posted December 20, 2009 Well, if you're running YouTube you'd also have load balancers and dedicated database boxes with lots of memory and fast disk I/O. They probably shove alot of the data in Memcached too. Quote Link to comment https://forums.phpfreaks.com/topic/185756-add-to-favorites-in-application/#findComment-980862 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.