From 69233fed43e23d88b590a4009f9d286ee16b67a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 23 Jan 2023 14:41:22 +0100 Subject: [PATCH] sql: add assembly table --- schema.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/schema.sql b/schema.sql index 7e0bc30..850a247 100644 --- a/schema.sql +++ b/schema.sql @@ -44,6 +44,16 @@ CREATE TABLE IF NOT EXISTS part ( FOREIGN KEY (package) REFERENCES package (id) ); +-- a project (as part) can be an assembly of other parts +CREATE TABLE IF NOT EXISTS assembly ( + assembled INTEGER NOT NULL, -- the assembly project + component INTEGER NOT NULL, -- the component part + quantity INTEGER NOT NULL, -- quantity of component + FOREIGN KEY (assembled) REFERENCES part (id), + FOREIGN KEY (component) REFERENCES part (id), + UNIQUE (assembled, component) +); + -- CAD drawing type CREATE TABLE IF NOT EXISTS cad ( id INTEGER AUTO_INCREMENT PRIMARY KEY, -- index