adding sql and additional supporting sql for Similarity matrix problem