array or new table for every user , which one ?
-
Hi everybody. I have a problem. I am trying to make a little social network. Users can add other users to own people list. So what should i do ? Should i create a new table for every user? ( for example 2000 table for 2000 users ) or should i create an array for every user ? After i can save the array to the database. or any other way ? whick way is the best ? İf array is the best , how can i do it ? first user have 2 friends , second user have 19 friend. array size is different. So what should i do ?
-
Hi everybody. I have a problem. I am trying to make a little social network. Users can add other users to own people list. So what should i do ? Should i create a new table for every user? ( for example 2000 table for 2000 users ) or should i create an array for every user ? After i can save the array to the database. or any other way ? whick way is the best ? İf array is the best , how can i do it ? first user have 2 friends , second user have 19 friend. array size is different. So what should i do ?
This is a classic case of a
Many to Many
relationship and what you need to do is create a linking table. You have the originalUsers
table with each user having a unique id UserID. Then you have another table call itFriends
with only 2 fields UserID and FriendID. Each time a user adds a friend, you just add a row to the linking table, using the UserID of the Friend as the FriendID in the friends table, and if they remove the friend, you just drop the row. Hope this makes sense.When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
-
This is a classic case of a
Many to Many
relationship and what you need to do is create a linking table. You have the originalUsers
table with each user having a unique id UserID. Then you have another table call itFriends
with only 2 fields UserID and FriendID. Each time a user adds a friend, you just add a row to the linking table, using the UserID of the Friend as the FriendID in the friends table, and if they remove the friend, you just drop the row. Hope this makes sense.When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
this could work ! Thank you !
-
this could work ! Thank you !
Glad to help :thumbsup:
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
-
this could work ! Thank you !