I have a question about how a bookmarking site like Reddit would manage all the 'votes' a user has logged.
For example when I (User_ID_292929) vote up a post (Post_ID_282828) logically somewhere in a database it says that User_ID_292929 has voted up Post_ID_282828.
But how would that be structuralized in the DB? Would the table that handels user profiles have a a field that is full of comma seperated values and it gets exploded and checked to see if the posts on the page that's being loaded has been voted up?
I'm not looking for a long answer but more a example program or documentation on a similar structure.
Thanks
Assuming a user can only vote a particular post once, then you could create a new table (let's call it users_vote_posts) with 2 columns (user_id and post_id). Set both user_id and post_id as a composite primary key.
Using your example, let's say a user (User_ID_292929) votes up a post (Post_ID_282828). The table would look like this:
+---------+---------+
| user_id | post_id |
+---------+---------+
| 292929 | 282828 |
+---------+---------+
If there are more than one type of vote (either vote up OR down for example) then you could add another column that defines the type of vote (let's call it vote_type).
Now the table would look like this:
+---------+---------+-----------+
| user_id | post_id | vote_type |
+---------+---------+-----------+
| 292929 | 282828 | up |
+---------+---------+-----------+