From 6e5f791a75adccf05a364373f9b7b6b8861477ab Mon Sep 17 00:00:00 2001 From: Max Chis <48846180+maxachis@users.noreply.github.com> Date: Sat, 8 Nov 2025 15:36:33 -0500 Subject: [PATCH] Revise link table guidelines in DESIGN-PRINCIPLES.md Updated guidelines for link tables to remove the separate 'id' column and enforce naming conventions. --- DESIGN-PRINCIPLES.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/DESIGN-PRINCIPLES.md b/DESIGN-PRINCIPLES.md index 9fe02b8..7b14ca0 100644 --- a/DESIGN-PRINCIPLES.md +++ b/DESIGN-PRINCIPLES.md @@ -239,12 +239,9 @@ The following columns should be present in all tables unless there is a compelli ## Link Tables -- Link tables should have an `id` column that is separate from the foreign keys. - - Often, this column is not used, but consistency is preferred over eliminating redundancy. -- Link tables should have a `link_` prefix, and the table names should be singular or plural depending on the relationship. e.g.: - - one-to-one: `link_apple_orange` - - one-to-many: `link_apple_oranges` - - many-to-many: `link_apples_oranges` +- Link tables should NOT have an `id` column that is separate from the foreign keys. + - This key is often redundant and never used -- a link table is typically referenced by the two linking tables. +- Link tables should always be in the format of `link_{table_a}__{table_b}`, and the tables should always be in alphabetical order, to avoid confusion when remembering which comes first. - Link tables should have unique constraints reflective of the particular relationship: - one-to-one: separate unique constraints on each foreign key column - one-to-many: unique constraint on the `one` column