Storing a Friendship: SQL Server Indexed Views, Part 2
You're building a social network and want to store who is friends with whom. OK. Let's assume you want Facebook-style friends: by agreeing to be friends with someone you allow them to be friends with you too. This is called a symmetric relationship and if your social model sticks to that kind of relationship, your application should enforce its symmetry.
How shall we store friends in a database table? There are several options.
Initiator first
A table with one record per friendship and two fields for each of the friends. The person who requested the friendship is stored in the first field:
The link to techpro resulted in a 404 error.
Thomas
21 Nov 16 at 08:33