Tautological foreign key

  • Discourse touched me in a no-no place

    Didn't know you could do that. Don't know why you would do that

  • SockDev

    yeah that's a self reference foreign key.

    at a guess it's on a field named something like parentTicket and it associates the current ticket to another ticket.

  • SockDev

    Except here the PK and FK are the same column

  • So that when you do a join of the table with itself on that ID, you get a stack overflow?

    Well, no, that doesn't happen.

    Maybe it's to get the ORM modeler lost indefinitely?

  • SockDev

    oh. missed that.

    yeah that's..... an interesting relationship.

  • Oogway: When the path you walk always leads back to yourself, you never get anywhere.

  • Sounds like the DB way of checking equality multiple times. Just to make sure.

  • Strangely, this is the default in SSMS when you click the button to create a new foreign key. I wondered if this condition would prevent new rows from being added, but my testing shows it doesn't.

  • I guess MSS evaluates it to a no-op and ignores it to guard against people leaving the defaults and killing their DB without knowing why, they love doing stuff like that.

  • I'm dissapoint there is no wooden table involved in your screen capturing workflow

  • Discourse touched me in a no-no place

    I don't tdwtf from my work computer. I have too much vitriolic complaining to do and too high of a security monitoring profile. Therefore cell phones.

Log in to reply

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.