Explained junction tables

This commit is contained in:
lucast committed 2026-11-23 10:43:02 +01:00
1 parent df49bfa6aa
commit f81de3e654
1 file changed
+8
+8
View File
@@ -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. 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.<br />
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.<br />
I also added composite unique constraints where it depends on multiple columns, such as the car model's name within a brand.
### PostgreSQL constraints. ### PostgreSQL constraints.
I wanted to add the CHECK constraint in PostgreSQL.<br /> I wanted to add the CHECK constraint in PostgreSQL.<br />