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