Compare commits
No commits in common. "6c19b77768c57f1f57d405d5145c3a664f409e7f" and "45f76eab171008b6cf6078b55961b420965934ba" have entirely different histories.
6c19b77768
...
45f76eab17
4 changed files with 1 additions and 79 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
.idea
|
.idea
|
||||||
db/*
|
|
|
@ -1,12 +0,0 @@
|
||||||
# Datenbank
|
|
||||||
|
|
||||||
## Aufsetzen - SQLite
|
|
||||||
|
|
||||||
Erstellen / Verbinden mit der Datenbank
|
|
||||||
```sqlite3 ../db/test.db```
|
|
||||||
|
|
||||||
Tabellen anlegen (nach Verbindung durch *sqlite3* besteht)
|
|
||||||
```.read create.sql```
|
|
||||||
|
|
||||||
In einem Schritt:
|
|
||||||
```sqlite3 ../db/test.db -init create.sql```
|
|
|
@ -1,62 +0,0 @@
|
||||||
CREATE TABLE IF NOT EXISTS mitglied (
|
|
||||||
mitglied_id INT NOT NULL PRIMARY KEY,
|
|
||||||
haushalt VARCHAR(100) NOT NULL,
|
|
||||||
erweiterter_haushalt VARCHAR(100),
|
|
||||||
einlage INT NOT NULL,
|
|
||||||
guthaben INT NOT NULL,
|
|
||||||
kontoauszuege BOOLEAN NOT NULL,
|
|
||||||
aktiv BOOLEAN NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS transaktion_art (
|
|
||||||
art_id INT NOT NULL PRIMARY KEY,
|
|
||||||
art VARCHAR(50) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT OR IGNORE INTO transaktion_art(art_id, art) VALUES (1, 'monatlicher_beitrag');
|
|
||||||
INSERT OR IGNORE INTO transaktion_art(art_id, art) VALUES (2, 'aufladung');
|
|
||||||
INSERT OR IGNORE INTO transaktion_art(art_id, art) VALUES (3, 'einkauf');
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS transaktion (
|
|
||||||
transaktion_id INT NOT NULL PRIMARY KEY,
|
|
||||||
mitglied_id INT NOT NULL,
|
|
||||||
art_id INT NOT NULL,
|
|
||||||
datum DATE NOT NULL,
|
|
||||||
BETRAG INT NOT NULL,
|
|
||||||
CONSTRAINT fk_mitglied_transaktion FOREIGN KEY (mitglied_id) REFERENCES mitglied(mitglied_id),
|
|
||||||
CONSTRAINT fk_art_transaktion FOREIGN KEY (art_id) REFERENCES transaktion_art(art_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS monatlicher_beitrag (
|
|
||||||
monatlicher_beitrag_id INT NOT NULL PRIMARY KEY,
|
|
||||||
mitglied_id INT NOT NULL,
|
|
||||||
anfangsdatum DATE NOT NULL,
|
|
||||||
enddatum DATE NOT NULL,
|
|
||||||
beitrag INT NOT NULL,
|
|
||||||
CONSTRAINT fk_mitglied_beitrag FOREIGN KEY (mitglied_id) REFERENCES mitglied(mitglied_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS mwst (
|
|
||||||
mwst_id INT NOT NULL PRIMARY KEY,
|
|
||||||
prozent INT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT OR IGNORE INTO mwst(mwst_id, prozent) VALUES (1, 7);
|
|
||||||
INSERT OR IGNORE INTO mwst(mwst_id, prozent) VALUES (2, 19);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS einheit(
|
|
||||||
einheit_id INT NOT NULL PRIMARY KEY,
|
|
||||||
bezeichnung VARCHAR(50) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT OR IGNORE INTO einheit(einheit_id, bezeichnung) VALUES (1, 'stueck');
|
|
||||||
INSERT OR IGNORE INTO einheit(einheit_id, bezeichnung) VALUES (2, 'menge');
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS artikel (
|
|
||||||
artikel_id INT NOT NULL PRIMARY KEY,
|
|
||||||
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)
|
|
||||||
);
|
|
|
@ -1,3 +0,0 @@
|
||||||
CREATE SERVER IF NOT EXISTS s
|
|
||||||
FOREIGN DATA WRAPPER mysql
|
|
||||||
OPTIONS (USER 'REMOTE', HOST '127.0.0.1', DATABASE 'test');
|
|
Loading…
Reference in a new issue