EXPLAIN EXTENDED

How to create fast database queries

Storing a Friendship: SQL Server Indexed Views, Part 2

with one comment

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:

Read the rest of this entry on tech.pro ยป

Written by Quassnoi

August 14th, 2013 at 11:00 pm

Posted in SQL Server

One Response to 'Storing a Friendship: SQL Server Indexed Views, Part 2'

Subscribe to comments with RSS

  1. The link to techpro resulted in a 404 error.

    Thomas

    21 Nov 16 at 08:33

Leave a Reply