Maxim Mironjuk
-
March 01, 2026
A classic many-to-many junction table offers two paths: using both foreign keys themselves as a composite primary key, or assigning a dedicated, independent surrogate ID. Both variants are technically valid, but they differ noticeably in uniqueness guarantees, index behavior, ORM compatibility, and the ability to cleanly reference later extra attributes. This article works out the concrete trade-offs using a typical junction table with extra attributes and shows when each approach is genuinely the better one.