From f81de3e65404348f2670072b32e2110776487d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20T=C3=A4kker?= Date: Mon, 23 Nov 2026 10:43:02 +0100 Subject: [PATCH] Explained junction tables --- Explanation.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Explanation.md b/Explanation.md index 3e7a3c4..43b70f4 100644 --- a/Explanation.md +++ b/Explanation.md @@ -18,6 +18,14 @@ When a WorkOrder is done it should in a transaction both set WorkOrder.status = All prices/rates is using an integer of "Øre" to avoid floating point precision problems, especially on larger amounts. +I used explicit junction tables to handle many-to-many relationships betwithout editing migration files.ween mechanics and skills, mechanics and work orders and spare parts and work orders. + +Some of those tables store extra information about the relationship itself, such as how many minutes a mechanic worked on a work order or the quantity and price of spare parts used.
+I store the price charged for each spare part in WorkOrderToSparePart rather than SparePart so previous work orders keep their original prices even if the price of the part changes. + +I used composite PKs in the junction tables to prevent duplicates.
+I also added composite unique constraints where it depends on multiple columns, such as the car model's name within a brand. + ### PostgreSQL constraints. I wanted to add the CHECK constraint in PostgreSQL.