Compare commits
No commits in common. "d711eef20d8ff7c36209ed7f630c37b252d39e24" and "5edef0200dac109491875733b6691fff9f521a0a" have entirely different histories.
d711eef20d
...
5edef0200d
4 changed files with 1 additions and 79 deletions
1
.gitignore
vendored
1
.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 INTO transaktion_art(art_id, art) VALUES (1, 'monatlicher_beitrag');
|
|
||||||
INSERT INTO transaktion_art(art_id, art) VALUES (2, 'aufladung');
|
|
||||||
INSERT 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 INTO mwst(mwst_id, prozent) VALUES (1, 7);
|
|
||||||
INSERT INTO mwst(mwst_id, prozent) VALUES (2, 19);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS einheit(
|
|
||||||
einheit_id INT NOT NULL PRIMARY KEY,
|
|
||||||
bezeichung VARCHAR(50) NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO einheit(menge_id, bezeichnung) VALUES (1, 'stueck');
|
|
||||||
INSERT INTO einheit(menge_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