Welcome Guest, Not a member yet? Register   Sign In
Been trying to find the solution! (help with database)
#5

[eluser]pickupman[/eluser]
As noxie mentioned and as a database practice, you don't want to repeat data. Two options:
1.) You can use implode() to create a delimited string like , or |. implode takes an array and converts them into a delimited string of your choosing.
2.) You could keep your existing user table, and add a friends table. You user table would have details about the user like name, email, a/s/l, and etc. Then create a new table for friends. Here you would create the connections between users by creating a entry for each connection by users.user_id = friends.friend_id.
+ user_id + friend_id +
+ 34 | 1 +
+ 1 | 34 +
+ 34 | 2 +
+ 34 | 3 +


Option 1 may be faster at first because you have one table to work with, and all of the data is in one spot. However, this option will much too cumbersome as your lists of users/friends grow. As searching a plain text/varchar field will become pretty slow and may be limiting the total number of users you can save in a row. It will also become difficult to properly update users profiles. Option 2 gives you room to grow, and much better data management.


Messages In This Thread
Been trying to find the solution! (help with database) - by El Forum - 06-29-2010, 05:33 AM
Been trying to find the solution! (help with database) - by El Forum - 06-29-2010, 05:46 AM
Been trying to find the solution! (help with database) - by El Forum - 06-29-2010, 05:58 AM
Been trying to find the solution! (help with database) - by El Forum - 06-29-2010, 06:06 AM
Been trying to find the solution! (help with database) - by El Forum - 06-29-2010, 07:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB