SQL · Microsoft · Hard
The relation FriendEdges(id INT PRIMARY KEY, user_from VARCHAR(10), user_to VARCHAR(10)) stores one directed follow edge per row. A friendship exists only when both directions are stored: u -> v and v -> u. Duplicate directed edges may appear in the table. Write a single SQL query that builds an undirected table Friends(u1, u2) from the reciprocal edges in FriendEdges. Every friendship must appear exactly once, with the lexicographically smaller user in u1 and the other user…
Checking your access…