I have to do a database design for a Friend-Network.
When I add someone as someone friend, I actually add their uniqueID to a table with two columns.
| USER 1 | USER 2 |
So when I want to known what are someone friends, I do a SELECT in this table looking for ID.
But the problem, is when I want to show the friend list i have to search all his friends, and after do a lookup for each ID looking for details.
It just does not look right.
Is there a more efficient way to do it? Could I design my database?
Is there any place where we can learn more about database design?
Your design seems fine to me. However look into JOINs which will help you get rid of nested queries to get info for the users. JOINs will allow you to get all the info about both users in one query and then you can loop through and print the list.
The query might become something like: