Duplicates in an edge table

As mentioned in the first subsection, in an edge table, you can connect any two nodes in the graph, regardless of their types. Therefore, you can have relational duplicates in the table. In relational tables, this is usually prevented by creating a primary key, as in the dbo.UserFollows relational table:

CONSTRAINT PK_UserFollows PRIMARY KEY CLUSTERED(    UserId ASC,    FollowingUserId ASC));

The primary key constraint will not let you enter the same pair of values for UserId and FollowingUserId again, but in the dbo.Follows edge table, this will be possible. The following statement will not fail:

INSERT INTO dbo.Follows VALUES('{"type":"node","schema":"dbo","table":"TwitterUser","id":0}','{"type":"node","schema":"dbo","table":"TwitterUser","id":1}'); ...

Get SQL Server 2017 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.