Skip to content

Commit

Permalink
Generalized tables
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCappelletti94 committed Feb 9, 2024
1 parent e06f94c commit 58edf55
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-- SQL defining the item_weights table.
-- SQL defining the item_real_quantities table.
-- Each item, being a physical object, has a weight. This table defines the weights of items.
-- The weight of an item may change over time, and be measured using different scales and by
-- different people.
CREATE TABLE item_weights (
CREATE TABLE item_real_quantities (
id SERIAL PRIMARY KEY,
item_id INTEGER REFERENCES items(id),
weight DECIMAL(10, 2) NOT NULL,
weight_unit_id INTEGER REFERENCES weight_units(id),
unit_id INTEGER REFERENCES units(id),
sensor_id INTEGER REFERENCES items(id),
measured_at TIMESTAMPTZ NOT NULL DEFAULT now(),
measured_by INTEGER REFERENCES users(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
created_by INTEGER NOT NULL REFERENCES users(id),
updated_by INTEGER NOT NULL REFERENCES users(id),
FOREIGN KEY (item_id, weight_unit_id) REFERENCES items(item_id, weight_unit_id),
FOREIGN KEY (item_id, unit_id) REFERENCES items(item_id, unit_id),
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- While these quantities are discrete, in order to facilitate the semantics of
-- the system, we will still allow for the user to specify the counter unit for
-- the item. For example, a counter unit may be a box, a tube, or a vial.
CREATE TABLE item_quantities (
CREATE TABLE item_discrete_quantities (
id SERIAL PRIMARY KEY,
item_id INTEGER REFERENCES items(id),
quantity INTEGER NOT NULL,
Expand Down

0 comments on commit 58edf55

Please sign in to comment.