Pa ja sam autoincrement shvatio u smislu povećanja od 1 do beskonačno. Ovdje bi išlo od 1 do, šta znam, nekad 3, nekad 5 ili 10, uglavnom ne nešto mnogo… Onda bi struktura baze trebala biti mijenjana, da se u toj nekoj tabeli autoincrement resetuje (ako se to tako radi). Ili sam na sasvim krivom tragu?
Doduše, nije ovo sad nešto vrijedno posebnog truda. Riješio sam macolom i radi.
Mislim da si na krivom tragu i da bi ti tabele trebale izgledati ovako:
orders:
id,
internal_code, // code on each order that is used by accountant for classification/identification/tax
total // total price of order got by multiplication and addition in order_product table
created_at,
updated_at
products:
id,
internal_code
name,
// more fields like `manufacturer`, `description`, other fields...
quantity // left on lager
unit_price
measurement_unit // default measurement unit pc, kg, m, l...
created_at
updated_at
order_product:
id
order_id
product_id
unit_price // for case if product price is changed in products table after order has been processed
quantity // this field should be updated from frontend among (following update in) orders.total
created_at
updated_at
1 Like
Hvala i na ovom rješenju.
1 Like
I to bi se dalo još doradjivati al’ za mene bi osnova izgledala ovako.
1 Like