Project:Inventory system: Difference between revisions

From London Hackspace Wiki

Line 37: Line 37:
; Relation: Similar objects can be linked together, this can be resolved recursively up to a limit.
; Relation: Similar objects can be linked together, this can be resolved recursively up to a limit.
; Log: All changes appear in a log with a change description, previous value, new value, user, and time.
; Log: All changes appear in a log with a change description, previous value, new value, user, and time.
=== Database schema ===
<pre>
CREATE TABLE category (
    id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY_KEY,
    title VARCHAR(255)
);
CREATE TABLE item (
    id          MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    title    VARCHAR(255)          NOT NULL UNIQUE,
    category      TINYINT UNSIGNED NOT NULL -- category.id
);
CREATE TABLE property (
    id          SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    category      TINYINT UNSIGNED NOT NULL DEFAULT 0, -- category.id -- IF 0 THEN common
    name    VARCHAR(255)          NOT NULL
);
CREATE TABLE item_properties (
    id                INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    item        MEDIUMINT UNSIGNED NOT NULL, -- item.id
    property    SMALLINT UNSIGNED NOT NULL, -- property.id
    `value`  VARCHAR(255)
);
CREATE TABLE queue (
    id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255)
);
-- Categories from which items may be a member of this queue.
CREATE TABLE queue_categories (
    id      SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    queue    TINYINT UNSIGNED NOT NULL, -- queue.id
    category  TINYINT UNSIGNED NOT NULL  -- category.id
);
-- items in a queue.
CREATE TABLE queue_items (
    id            INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    queue      TINYINT UNSIGNED NOT NULL, -- queue.id
    item    MEDIUMINT UNSIGNED NOT NULL, -- item.id
    resolved  BOOLEAN          DEFAULT NULL -- 0 = Ignored, 1 = Done, NULL = Pending
);
</pre>
1,143

edits