I have found an explanation for LinkTypeId 1 and 3 here. Why was the second type skipped?

  • It might not have been skipped, the value simply isn't made available in the public. I don't have access to the code base so I can only speculate. Maybe LinkTypeId =2 holds the Related information (see what is in the sidebar of the question: Linked is represented with LinkTypeId =1, Related might be represented with LinkTypeId = 2)
    – rene
    Jul 20 at 16:52

1 Answer 1


The data-dump and the Stack Exchange Data Explorer schema are limited selections of the actual production database schema. But when tables and/or data is made available the production schema is followed with filters/views applied to remove the data that should stay private, for various reasons.

In the production database LinkTypeId = 2 does occur. I already speculated on that but Twitter never forgets.

In that screenshot and tweet from Nick Craver we see him discuss improvements over this (paraphrased) query:

DECLARE @relatedMax tinyint = 10,
        @Questionid int = 309786;

Select Top(@relatedMax)
       Cast(Case When p.AcceptedAnswerid is Null Then 0 else 0 End as bit) HasAcceptedAnswer,
From PostLinks pl
     Join Posts p on pl.RelatedPostId = p.Id
Where pl.PostId = @QuestionId
  And pl.LinkTypeId = 2 -- {=Related}
  And p.DeletionDate is null;

In the Where clause we can confirm our gut feeling: LinkTypeId does take a value of 2 meaning "Related". As bonus we see further down a LinkTypeId with value 4 meaning "Collection"

So, to answer the question: The value 2 wasn't skipped. It is used in the production schema of the database. Unfortunately that value isn't made publicly available. You need the Stack API if you want those: How to get related questions' IDs of a certain question in Stack Overflow?

image captured from Twitter in case that Tweet ever gets deleted

  • This is irrelevant since there's no reason the values need to be consecutive or any particular values at all.
    – philipxy
    Jul 21 at 6:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .