From c4855046bb5078b0ea1b7a041530151c79619470 Mon Sep 17 00:00:00 2001 From: Nicksname Date: Sun, 25 Jun 2023 22:03:09 +0200 Subject: [PATCH] =?UTF-8?q?Kategorie=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_scripts/create.sql | 15 +++++++++++++-- db_scripts/drop.sql | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/db_scripts/create.sql b/db_scripts/create.sql index b7b1480..982e3ad 100644 --- a/db_scripts/create.sql +++ b/db_scripts/create.sql @@ -52,11 +52,22 @@ CREATE TABLE IF NOT EXISTS einheit( INSERT INTO einheit(einheit_id, bezeichnung) VALUES (1, 'stueck'); INSERT INTO einheit(einheit_id, bezeichnung) VALUES (2, 'menge'); +CREATE TABLE IF NOT EXISTS kategorie ( + kategorie_id INT NOT NULL PRIMARY KEY, + parent_id INT, + name VARCHAR(100) NOT NULL, + icon_unicode VARCHAR(100) NOT NULL, + CONSTRAINT fk_kategorie_tree FOREIGN KEY (parent_id) REFERENCES kategorie(kategorie_id) +); + CREATE TABLE IF NOT EXISTS artikel ( artikel_id INT NOT NULL PRIMARY KEY, + bezeichnung VARCHAR(255) NOT NULL, + kategorie_id INT NOT NULL, einheit_id INT NOT NULL, mwst_id INT NOT NULL, preis INT NOT NULL, CONSTRAINT fk_mwst_artikel FOREIGN KEY (mwst_id) REFERENCES mwst(mwst_id), - CONSTRAINT fk_einheit_artikel FOREIGN KEY (einheit_id) REFERENCES einheit(einheit_id) -); \ No newline at end of file + CONSTRAINT fk_einheit_artikel FOREIGN KEY (einheit_id) REFERENCES einheit(einheit_id), + CONSTRAINT fk_kategorie_artikel FOREIGN KEY (kategorie_id) REFERENCES kategorie(kategorie_id) +); diff --git a/db_scripts/drop.sql b/db_scripts/drop.sql index b22754a..b8af40a 100644 --- a/db_scripts/drop.sql +++ b/db_scripts/drop.sql @@ -5,3 +5,4 @@ DROP TABLE IF EXISTS monatlicher_beitrag; DROP TABLE IF EXISTS mwst; DROP TABLE IF EXISTS einheit; DROP TABLE IF EXISTS artikel; +DROP TABLE IF EXISTS kategorie;