• (nodebb)

    I half-suspect that's auto-generated code. The rule says "When connecting two tables, make sure there's a FK constraint between them so there can't be orphan records". So when the dumb SQL generator code was told to connect table A to table A, it mindlessly added the appropriate FK constraint.

    But where's the fun in that? Better to think it was a clueless self-taught noob. Or more likely somebody who took, passed, but understood none of, Databases 201.

  • (nodebb) in reply to WTFGuy

    I agree on the autogenerated but I think this is probably the result of someone accidentally dragging the PK column while using a table/diagram designer like the one that has been included with SSMS since forever, the same one that produces names like PK__Configur__F6E145D05992BA46 and DF__Configura__KtCal__7F23583C.

  • Hmmmm 🤨 (unregistered)
    Comment held for moderation.
  • (nodebb)

    having a ManagerId field is a terrible choice,

    The only smart thing I've ever done is realized that I'm not as smart as I think I am, so I'll ask all y'all if my answer to the above is correct: the proper way to handle that is to have a separate mapping table with an [EmployeeID] column and a [ManagerID] column.

    Yes? No?

    Addendum 2026-11-05 09:27: . . . both of which are foreign keys to the [Employee] table.

Leave a comment on “Only Create Me if I Exist”

Log In or post as a guest

Replying to comment #705952:

« Return to Article