diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml new file mode 100644 index 0000000..509426b --- /dev/null +++ b/.idea/dataSources.local.xml @@ -0,0 +1,22 @@ + + + + + + #@ + ` + + + master_key + root + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..16901da --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + mariadb + true + org.mariadb.jdbc.Driver + jdbc:mariadb://localhost:3306 + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/dataSources/a1d1df29-b94a-4ad6-bd6f-a458b97a6c0c.xml b/.idea/dataSources/a1d1df29-b94a-4ad6-bd6f-a458b97a6c0c.xml new file mode 100644 index 0000000..135e892 --- /dev/null +++ b/.idea/dataSources/a1d1df29-b94a-4ad6-bd6f-a458b97a6c0c.xml @@ -0,0 +1,1607 @@ + + + + + lower/lower + InnoDB + |root||root|127.0.0.1|ALTER|G +|root||root|::1|ALTER|G +|root||root|localhost|ALTER|G +|root||root|robert-pc|ALTER|G +|root||root|127.0.0.1|ALTER ROUTINE|G +|root||root|::1|ALTER ROUTINE|G +|root||root|localhost|ALTER ROUTINE|G +|root||root|robert-pc|ALTER ROUTINE|G +|root||root|127.0.0.1|BINLOG ADMIN|G +|root||root|::1|BINLOG ADMIN|G +|root||root|localhost|BINLOG ADMIN|G +|root||root|robert-pc|BINLOG ADMIN|G +|root||root|127.0.0.1|BINLOG MONITOR|G +|root||root|::1|BINLOG MONITOR|G +|root||root|localhost|BINLOG MONITOR|G +|root||root|robert-pc|BINLOG MONITOR|G +|root||root|127.0.0.1|BINLOG REPLAY|G +|root||root|::1|BINLOG REPLAY|G +|root||root|localhost|BINLOG REPLAY|G +|root||root|robert-pc|BINLOG REPLAY|G +|root||root|127.0.0.1|CONNECTION ADMIN|G +|root||root|::1|CONNECTION ADMIN|G +|root||root|localhost|CONNECTION ADMIN|G +|root||root|robert-pc|CONNECTION ADMIN|G +|root||root|127.0.0.1|CREATE|G +|root||root|::1|CREATE|G +|root||root|localhost|CREATE|G +|root||root|robert-pc|CREATE|G +|root||root|127.0.0.1|CREATE ROUTINE|G +|root||root|::1|CREATE ROUTINE|G +|root||root|localhost|CREATE ROUTINE|G +|root||root|robert-pc|CREATE ROUTINE|G +|root||root|127.0.0.1|CREATE TABLESPACE|G +|root||root|::1|CREATE TABLESPACE|G +|root||root|localhost|CREATE TABLESPACE|G +|root||root|robert-pc|CREATE TABLESPACE|G +|root||root|127.0.0.1|CREATE TEMPORARY TABLES|G +|root||root|::1|CREATE TEMPORARY TABLES|G +|root||root|localhost|CREATE TEMPORARY TABLES|G +|root||root|robert-pc|CREATE TEMPORARY TABLES|G +|root||root|127.0.0.1|CREATE USER|G +|root||root|::1|CREATE USER|G +|root||root|localhost|CREATE USER|G +|root||root|robert-pc|CREATE USER|G +|root||root|127.0.0.1|CREATE VIEW|G +|root||root|::1|CREATE VIEW|G +|root||root|localhost|CREATE VIEW|G +|root||root|robert-pc|CREATE VIEW|G +|root||root|127.0.0.1|DELETE|G +|root||root|::1|DELETE|G +|root||root|localhost|DELETE|G +|root||root|robert-pc|DELETE|G +|root||root|127.0.0.1|DELETE HISTORY|G +|root||root|::1|DELETE HISTORY|G +|root||root|localhost|DELETE HISTORY|G +|root||root|robert-pc|DELETE HISTORY|G +|root||root|127.0.0.1|DROP|G +|root||root|::1|DROP|G +|root||root|localhost|DROP|G +|root||root|robert-pc|DROP|G +|root||root|127.0.0.1|EVENT|G +|root||root|::1|EVENT|G +|root||root|localhost|EVENT|G +|root||root|robert-pc|EVENT|G +|root||root|127.0.0.1|EXECUTE|G +|root||root|::1|EXECUTE|G +|root||root|localhost|EXECUTE|G +|root||root|robert-pc|EXECUTE|G +|root||root|127.0.0.1|FEDERATED ADMIN|G +|root||root|::1|FEDERATED ADMIN|G +|root||root|localhost|FEDERATED ADMIN|G +|root||root|robert-pc|FEDERATED ADMIN|G +|root||root|127.0.0.1|FILE|G +|root||root|::1|FILE|G +|root||root|localhost|FILE|G +|root||root|robert-pc|FILE|G +|root||root|127.0.0.1|INDEX|G +|root||root|::1|INDEX|G +|root||root|localhost|INDEX|G +|root||root|robert-pc|INDEX|G +|root||root|127.0.0.1|INSERT|G +|root||root|::1|INSERT|G +|root||root|localhost|INSERT|G +|root||root|robert-pc|INSERT|G +|root||root|127.0.0.1|LOCK TABLES|G +|root||root|::1|LOCK TABLES|G +|root||root|localhost|LOCK TABLES|G +|root||root|robert-pc|LOCK TABLES|G +|root||root|127.0.0.1|PROCESS|G +|root||root|::1|PROCESS|G +|root||root|localhost|PROCESS|G +|root||root|robert-pc|PROCESS|G +|root||root|127.0.0.1|READ_ONLY ADMIN|G +|root||root|::1|READ_ONLY ADMIN|G +|root||root|localhost|READ_ONLY ADMIN|G +|root||root|robert-pc|READ_ONLY ADMIN|G +|root||root|127.0.0.1|REFERENCES|G +|root||root|::1|REFERENCES|G +|root||root|localhost|REFERENCES|G +|root||root|robert-pc|REFERENCES|G +|root||root|127.0.0.1|RELOAD|G +|root||root|::1|RELOAD|G +|root||root|localhost|RELOAD|G +|root||root|robert-pc|RELOAD|G +|root||root|127.0.0.1|REPLICATION MASTER ADMIN|G +|root||root|::1|REPLICATION MASTER ADMIN|G +|root||root|localhost|REPLICATION MASTER ADMIN|G +|root||root|robert-pc|REPLICATION MASTER ADMIN|G +|root||root|127.0.0.1|REPLICATION SLAVE|G +|root||root|::1|REPLICATION SLAVE|G +|root||root|localhost|REPLICATION SLAVE|G +|root||root|robert-pc|REPLICATION SLAVE|G +|root||root|127.0.0.1|REPLICATION SLAVE ADMIN|G +|root||root|::1|REPLICATION SLAVE ADMIN|G +|root||root|localhost|REPLICATION SLAVE ADMIN|G +|root||root|robert-pc|REPLICATION SLAVE ADMIN|G +|root||root|127.0.0.1|SELECT|G +|root||root|::1|SELECT|G +|root||root|localhost|SELECT|G +|root||root|robert-pc|SELECT|G +|root||root|127.0.0.1|SET USER|G +|root||root|::1|SET USER|G +|root||root|localhost|SET USER|G +|root||root|robert-pc|SET USER|G +|root||root|127.0.0.1|SHOW DATABASES|G +|root||root|::1|SHOW DATABASES|G +|root||root|localhost|SHOW DATABASES|G +|root||root|robert-pc|SHOW DATABASES|G +|root||root|127.0.0.1|SHOW VIEW|G +|root||root|::1|SHOW VIEW|G +|root||root|localhost|SHOW VIEW|G +|root||root|robert-pc|SHOW VIEW|G +|root||root|127.0.0.1|SHUTDOWN|G +|root||root|::1|SHUTDOWN|G +|root||root|localhost|SHUTDOWN|G +|root||root|robert-pc|SHUTDOWN|G +|root||root|127.0.0.1|SLAVE MONITOR|G +|root||root|::1|SLAVE MONITOR|G +|root||root|localhost|SLAVE MONITOR|G +|root||root|robert-pc|SLAVE MONITOR|G +|root||root|127.0.0.1|SUPER|G +|root||root|::1|SUPER|G +|root||root|localhost|SUPER|G +|root||root|robert-pc|SUPER|G +|root||root|127.0.0.1|TRIGGER|G +|root||root|::1|TRIGGER|G +|root||root|localhost|TRIGGER|G +|root||root|robert-pc|TRIGGER|G +|root||root|127.0.0.1|UPDATE|G +|root||root|::1|UPDATE|G +|root||root|localhost|UPDATE|G +|root||root|robert-pc|UPDATE|G +|root||root|127.0.0.1|grant option|G +|root||root|::1|grant option|G +|root||root|localhost|grant option|G +|root||root|robert-pc|grant option|G + 11.1.3 + + + armscii8 + + + armscii8 + 1 + + + armscii8 + + + armscii8 + + + ascii + + + ascii + 1 + + + ascii + + + ascii + + + big5 + + + big5 + 1 + + + big5 + + + big5 + + + binary + 1 + + + cp1250 + + + cp1250 + + + cp1250 + + + cp1250 + 1 + + + cp1250 + + + cp1250 + + + cp1250 + + + cp1251 + + + cp1251 + + + cp1251 + 1 + + + cp1251 + + + cp1251 + + + cp1251 + + + cp1251 + + + cp1256 + + + cp1256 + 1 + + + cp1256 + + + cp1256 + + + cp1257 + + + cp1257 + 1 + + + cp1257 + + + cp1257 + + + cp1257 + + + cp850 + + + cp850 + 1 + + + cp850 + + + cp850 + + + cp852 + + + cp852 + 1 + + + cp852 + + + cp852 + + + cp866 + + + cp866 + 1 + + + cp866 + + + cp866 + + + cp932 + + + cp932 + 1 + + + cp932 + + + cp932 + + + dec8 + + + dec8 + + + dec8 + 1 + + + dec8 + + + eucjpms + + + eucjpms + 1 + + + eucjpms + + + eucjpms + + + euckr + + + euckr + 1 + + + euckr + + + euckr + + + gb2312 + + + gb2312 + 1 + + + gb2312 + + + gb2312 + + + gbk + + + gbk + 1 + + + gbk + + + gbk + + + geostd8 + + + geostd8 + 1 + + + geostd8 + + + geostd8 + + + greek + + + greek + 1 + + + greek + + + greek + + + hebrew + + + hebrew + 1 + + + hebrew + + + hebrew + + + hp8 + + + hp8 + 1 + + + hp8 + + + hp8 + + + keybcs2 + + + keybcs2 + 1 + + + keybcs2 + + + keybcs2 + + + koi8r + + + koi8r + 1 + + + koi8r + + + koi8r + + + koi8u + + + koi8u + 1 + + + koi8u + + + koi8u + + + latin1 + + + latin1 + + + latin1 + + + latin1 + + + latin1 + + + latin1 + + + latin1 + + + latin1 + + + latin1 + 1 + + + latin1 + + + latin2 + + + latin2 + + + latin2 + + + latin2 + 1 + + + latin2 + + + latin2 + + + latin2 + + + latin5 + + + latin5 + + + latin5 + 1 + + + latin5 + + + latin7 + + + latin7 + + + latin7 + 1 + + + latin7 + + + latin7 + + + latin7 + + + macce + + + macce + 1 + + + macce + + + macce + + + macroman + + + macroman + 1 + + + macroman + + + macroman + + + sjis + + + sjis + 1 + + + sjis + + + sjis + + + swe7 + + + swe7 + + + swe7 + 1 + + + swe7 + + + tis620 + + + tis620 + + + tis620 + 1 + + + tis620 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + 1 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ucs2 + + + ujis + + + ujis + 1 + + + ujis + + + ujis + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + 1 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16 + + + utf16le + + + utf16le + 1 + + + utf16le + + + utf16le + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + 1 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf32 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + 1 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb3 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + 1 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + utf8mb4 + + + 2023-11-24.21:00:41 + 2023-11-24.19:00:41 + latin1_swedish_ci + + + utf8mb3_general_ci + + + latin1_swedish_ci + + + utf8mb3_general_ci + + + utf8mb3_general_ci + + + localhost + + + 127.0.0.1 + + + ::1 + + + localhost + + + robert-pc + + + InnoDB + latin1_swedish_ci +
+ + InnoDB + latin1_swedish_ci +
+ + InnoDB + latin1_swedish_ci +
+ + InnoDB + latin1_swedish_ci +
+ + InnoDB + latin1_swedish_ci +
+ + InnoDB + latin1_swedish_ci +
+ + char(4)|0s + 1 + 1 + + + varchar(300)|0s + 1 + 2 + + + varchar(20)|0s + 1 + 3 + + + code + btree + 1 + + + 1 + 1 + PRIMARY + + + int(11)|0s + 1 + 1 + + + bigint(20)|0s + 2 + + + id + btree + 1 + + + 1 + 1 + PRIMARY + + + 21 + bigint(20)|0s + 1 + 1 + + + varchar(80)|0s + 1 + 2 + + + varchar(80)|0s + 1 + 3 + + + date|0s + 1 + 4 + + + tinyint(1)|0s + 1 + 5 + + + tinyint(1)|0s + 1 + 6 + + + double|0s + 1 + 7 + + + double|0s + 1 + 8 + + + id + btree + 1 + + + name + btree + 1 + + + 1 + 1 + PRIMARY + + + name + + + char(4)|0s + 1 + + + bigint(20)|0s + 1 + 2 + + + code + code + allergen + + + gericht_id + id + gericht + + + code + btree + + + gericht_id + btree + + + bigint(20)|0s + 1 + 1 + + + bigint(20)|0s + 1 + 2 + + + gericht_id + id + gericht + + + kategorie_id + id + kategorie + + + gericht_id + btree + + + kategorie_id + btree + + + bigint(20)|0s + 1 + 1 + + + varchar(80)|0s + 1 + 2 + + + bigint(20)|0s + 3 + + + varchar(200)|0s + 4 + + + eltern_id + id + kategorie + + + id + btree + 1 + + + eltern_id + btree + + + 1 + 1 + PRIMARY + +
+
\ No newline at end of file diff --git a/.idea/dataSources/a1d1df29-b94a-4ad6-bd6f-a458b97a6c0c/storage_v2/_src_/schema/emensawerbeseite.YLWk-w.meta b/.idea/dataSources/a1d1df29-b94a-4ad6-bd6f-a458b97a6c0c/storage_v2/_src_/schema/emensawerbeseite.YLWk-w.meta new file mode 100644 index 0000000..1196377 --- /dev/null +++ b/.idea/dataSources/a1d1df29-b94a-4ad6-bd6f-a458b97a6c0c/storage_v2/_src_/schema/emensawerbeseite.YLWk-w.meta @@ -0,0 +1,2 @@ +#n:emensawerbeseite +! [1700856041000, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/sqlDataSources.xml b/.idea/sqlDataSources.xml new file mode 100644 index 0000000..219de65 --- /dev/null +++ b/.idea/sqlDataSources.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..0c5bd08 --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..d41f5cc --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1700736495450 + + + + + + \ No newline at end of file diff --git a/M3/Datenbank_erstellen.txt b/M3/Datenbank_erstellen.txt new file mode 100644 index 0000000..0ca5288 --- /dev/null +++ b/M3/Datenbank_erstellen.txt @@ -0,0 +1,166 @@ +create or replace database emensawerbeseite; + +use emensawerbeseite; + +create table gericht ( + id int8 primary key auto_increment, + name varchar(80) not null unique, + beschreibung varchar(80) not null, + erfasst_am date not null, + vegetarisch boolean not null, + vegan boolean not null, + preisintern double not null, + preisextern double not null +); + + +create table allergen( + code char(4) primary key , + name varchar(300) not null, + typ varchar(20) not null +); + +create table kategorie( + id int8 primary key , + name varchar(80) not null, + eltern_id int8 , + CONSTRAINT FOREIGN KEY (eltern_id) REFERENCES kategorie(id), + bildname varchar(200) +); + +create table gericht_hat_allergen( + code char(4), + CONSTRAINT FOREIGN KEY (code) REFERENCES allergen(code), + gericht_id int8 not null, + CONSTRAINT FOREIGN KEY (gericht_id) REFERENCES gericht(id) +); + +create table gericht_hat_kategorie( + gericht_id int8 not null, + CONSTRAINT FOREIGN KEY (gericht_id) REFERENCES gericht(id), + kategorie_id int8 not null, + CONSTRAINT FOREIGN KEY (kategorie_id) REFERENCES kategorie(id) +); + +create table besucher_counter( + id int primary key, + besucher int8 +); + + +INSERT INTO `besucher_counter` () +VALUES (1,1); + + +INSERT INTO `allergen` (`code`, `name`, `typ`) VALUES + ('a', 'Getreideprodukte', 'Getreide (Gluten)'), + ('a1', 'Weizen', 'Allergen'), + ('a2', 'Roggen', 'Allergen'), + ('a3', 'Gerste', 'Allergen'), + ('a4', 'Dinkel', 'Allergen'), + ('a5', 'Hafer', 'Allergen'), + ('a6', 'Dinkel', 'Allergen'), + ('b', 'Fisch', 'Allergen'), + ('c', 'Krebstiere', 'Allergen'), + ('d', 'Schwefeldioxid/Sulfit', 'Allergen'), + ('e', 'Sellerie', 'Allergen'), + ('f', 'Milch und Laktose', 'Allergen'), + ('f1', 'Butter', 'Allergen'), + ('f2', 'Käse', 'Allergen'), + ('f3', 'Margarine', 'Allergen'), + ('g', 'Sesam', 'Allergen'), + ('h', 'Nüsse', 'Allergen'), + ('h1', 'Mandeln', 'Allergen'), + ('h2', 'Haselnüsse', 'Allergen'), + ('h3', 'Walnüsse', 'Allergen'), + ('i', 'Erdnüsse', 'Allergen'); + +INSERT INTO `gericht` (`id`, `name`, `beschreibung`, `erfasst_am`, `vegan`, `vegetarisch`, `preisintern`, `preisextern`) VALUES + (1, 'Bratkartoffeln mit Speck und Zwiebeln', 'Kartoffeln mit Zwiebeln und gut Speck', '2020-08-25', 0, 0, 2.3, 4), + (3, 'Bratkartoffeln mit Zwiebeln', 'Kartoffeln mit Zwiebeln und ohne Speck', '2020-08-25', 1, 1, 2.3, 4), + (4, 'Grilltofu', 'Fein gewürzt und mariniert', '2020-08-25', 1, 1, 2.5, 4.5), + (5, 'Lasagne', 'Klassisch mit Bolognesesoße und Creme Fraiche', '2020-08-24', 0, 0, 2.5, 4.5), + (6, 'Lasagne vegetarisch', 'Klassisch mit Sojagranulatsoße und Creme Fraiche', '2020-08-24', 0, 1, 2.5, 4.5), + (7, 'Hackbraten', 'Nicht nur für Hacker', '2020-08-25', 0, 0, 2.5, 4), + (8, 'Gemüsepfanne', 'Gesundes aus der Region, deftig angebraten', '2020-08-25', 1, 1, 2.3, 4), + (9, 'Hühnersuppe', 'Suppenhuhn trifft Petersilie', '2020-08-25', 0, 0, 2, 3.5), + (10, 'Forellenfilet', 'mit Kartoffeln und Dilldip', '2020-08-22', 0, 0, 3.8, 5), + (11, 'Kartoffel-Lauch-Suppe', 'der klassische Bauchwärmer mit frischen Kräutern', '2020-08-22', 0, 1, 2, 3), + (12, 'Kassler mit Rosmarinkartoffeln', 'dazu Salat und Senf', '2020-08-23', 0, 0, 3.8, 5.2), + (13, 'Drei Reibekuchen mit Apfelmus', 'grob geriebene Kartoffeln aus der Region', '2020-08-23', 0, 1, 2.5, 4.5), + (14, 'Pilzpfanne', 'die legendäre Pfanne aus Pilzen der Saison', '2020-08-23', 0, 1, 3, 5), + (15, 'Pilzpfanne vegan', 'die legendäre Pfanne aus Pilzen der Saison ohne Käse', '2020-08-24', 1, 1, 3, 5), + (16, 'Käsebrötchen', 'schmeckt vor und nach dem Essen', '2020-08-24', 0, 1, 1, 1.5), + (17, 'Schinkenbrötchen', 'schmeckt auch ohne Hunger', '2020-08-25', 0, 0, 1.25, 1.75), + (18, 'Tomatenbrötchen', 'mit Schnittlauch und Zwiebeln', '2020-08-25', 1, 1, 1, 1.5), + (19, 'Mousse au Chocolat', 'sahnige schweizer Schokolade rundet jedes Essen ab', '2020-08-26', 0, 1, 1.25, 1.75), + (20, 'Suppenkreation á la Chef', 'was verschafft werden muss, gut und günstig', '2020-08-26', 0, 0, 0.5, 0.9); + +INSERT INTO `gericht_hat_allergen` (`code`, `gericht_id`) VALUES + ('h', 1), + ('a3', 1), + ('a4', 1), + ('f1', 3), + ('a6', 3), + ('i', 3), + ('a3', 4), + ('f1', 4), + ('a4', 4), + ('h3', 4), + ('d', 6), + ('h1',7), + ('a2', 7), + ('h3', 7), + ('c', 7), + ('a3', 8), + ('h3', 10), + ('d', 10), + ('f', 10), + ('f2', 12), + ('h1', 12), + ('a5',12), + ('c', 1), + ('a2', 9), + ('i', 14), + ('f1', 1), + ('a1', 15), + ('a4', 15), + ('i', 15), + ('f3', 15), + ('h3', 15); + +INSERT INTO `kategorie` (`id`, `eltern_id`, `name`, `bildname`) VALUES + (1, NULL, 'Aktionen', 'kat_aktionen.png'), + (2, NULL, 'Menus', 'kat_menu.gif'), + (3, 2, 'Hauptspeisen', 'kat_menu_haupt.bmp'), + (4, 2, 'Vorspeisen', 'kat_menu_vor.svg'), + (5, 2, 'Desserts', 'kat_menu_dessert.pic'), + (6, 1, 'Mensastars', 'kat_stars.tif'), + (7, 1, 'Erstiewoche', 'kat_erties.jpg'); + +INSERT INTO `gericht_hat_kategorie` (`kategorie_id`, `gericht_id`) VALUES + (3, 1), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 9), (4, 16), (4, 17), (4, 18), (5, 16), (5, 17), (5, 18); + + + + +SELECT DISTINCT name, GROUP_CONCAT(code) FROM gericht g JOIN gericht_hat_allergen a ON g.id = a.gericht_id GROUP BY name ASC; + +SELECT DISTINCT name, GROUP_CONCAT(code) FROM gericht g LEFT JOIN gericht_hat_allergen a ON g.id = a.gericht_id GROUP BY name ASC +; +SELECT DISTINCT allergen.code, GROUP_CONCAT(gericht.name) AS gericht FROM allergen +LEFT JOIN gericht_hat_allergen on allergen.code = gericht_hat_allergen.code +LEFT JOIN gericht ON gericht_hat_allergen.gericht_id = gericht_id +GROUP BY allergen.name +ORDER BY code ASC; + + +SELECT kategorie.name, COUNT(kategorie_id) AS anzahl FROM gericht_hat_kategorie, kategorie +WHERE kategorie.id = gericht_hat_kategorie.kategorie_id +GROUP BY kategorie_id +ORDER BY anzahl ASC; + +SELECT kategorie.name, COUNT(kategorie_id) AS anzahl FROM gericht_hat_kategorie, kategorie +WHERE kategorie.id = gericht_hat_kategorie.kategorie_id AND kategorie_id > 2 +GROUP BY kategorie_id +ORDER BY anzahl ASC; \ No newline at end of file diff --git a/M3/Diagram.drawio.png b/M3/Diagram.drawio.png new file mode 100644 index 0000000..f4e2ae9 Binary files /dev/null and b/M3/Diagram.drawio.png differ diff --git a/M3/M3.md b/M3/M3.md index d823256..9e265ef 100644 --- a/M3/M3.md +++ b/M3/M3.md @@ -52,4 +52,67 @@ INSERT INTO gericht_hat_kategorie VALUES (21, 3); ``` +# Aufgabe 6 +## Abfragen + +1) Alle Gerichte mit allen zugehörigen Allergenen +``` sql +SELECT DISTINCT name, GROUP_CONCAT(code) FROM gericht g JOIN gericht_hat_allergen a ON g.id = a.gericht_id GROUP BY name ASC; +``` +2) Ändern Sie die vorherige Abfrage so ab, dass alle existierenden Gerichte dargestellt werden (auch wenn keine Allergene enthalten sind). +``` sql +SELECT DISTINCT name, GROUP_CONCAT(code) FROM gericht g LEFT JOIN gericht_hat_allergen a ON g.id = a.gericht_id GROUP BY name ASC; +``` +3) Ändern Sie die vorherige Abfrage so ab, so dass im Ergebnis alle existierenden Allergene dargestellt werden (auch wenn diese nicht einem Gericht zugeordnet sind). +``` sql +SELECT DISTINCT allergen.code, GROUP_CONCAT(gericht.name) AS gericht FROM allergen LEFT JOIN gericht_hat_allergen on allergen.code = gericht_hat_allergen.code LEFT JOIN gericht ON gericht_hat_allergen.gericht_id = gericht_id +GROUP BY allergen.name +ORDER BY code ASC; +``` +4) Die Anzahl der Gerichte pro Kategorie aufsteigend sortiert nach Anzahl. +``` sql +SELECT kategorie.name, COUNT(kategorie_id) AS anzahl FROM gericht_hat_kategorie, kategorie +WHERE kategorie.id = gericht_hat_kategorie.kategorie_id +GROUP BY kategorie_id +ORDER BY anzahl ASC; +``` +5) Ändern Sie die vorherige Abfrage so ab, dass dabei nur die Kategorien dargestellt werden, die mehr als 2 Gerichte besitzen. +``` sql +SELECT kategorie.name, COUNT(kategorie_id) AS anzahl FROM gericht_hat_kategorie, kategorie +WHERE kategorie.id = gericht_hat_kategorie.kategorie_id AND kategorie_id > 2 +GROUP BY kategorie_id +ORDER BY anzahl ASC; +``` + + +# Aufgabe 7 +elter_kategorie: +``` sql +FOREIGN KEY (id) REFERENCES kategorie(id), +``` + +gericht_hat_allergen: +``` sql +code char(4), +FOREIGN KEY (code) REFERENCES allergen(code), +gericht_id int8 not null, +FOREIGN KEY (gericht_id) REFERENCES gericht(id) + +``` + +gericht_hat_kategorie: +``` sql +gericht_id int8 not null, +FOREIGN KEY (gericht_id) REFERENCES gericht(id), +kategorie_id int8 not null, +FOREIGN KEY (kategorie_id) REFERENCES kategorie(id) + +``` +# Aufgabe 11 + +## Relationenmodell + +Kontakte(\_KontaktId\_,Vorname, Nachname, Email, Telefonnummer, Anrede, Typ, ) +Kunde(\_KontaktId\_) +Lieferant(\_KontaktId\_,Wochentag_fuer_Lieferzeitraum) \ No newline at end of file diff --git a/M3/Werbeseite/besucher.txt b/M3/Werbeseite/besucher.txt index 2d73b5e..cc4f7f3 100644 --- a/M3/Werbeseite/besucher.txt +++ b/M3/Werbeseite/besucher.txt @@ -1 +1 @@ -152 \ No newline at end of file +218 \ No newline at end of file diff --git a/M3/Werbeseite/index.php b/M3/Werbeseite/index.php index b4e1fb1..20afe7f 100644 --- a/M3/Werbeseite/index.php +++ b/M3/Werbeseite/index.php @@ -11,11 +11,18 @@ $besucherCount = 0; $newletterCount = 0; // Datenbankanbindung +//$link = mysqli_connect( + //"127.0.0.1", // Host der Datenbank + //"root", // Benutzername zur Anmeldung + //"wm#32", // Passwort + //"emensawerbeseite" // Auswahl der Datenbanken (bzw. des Schemas) +//); + $link = mysqli_connect( - "127.0.0.1", // Host der Datenbank - "root", // Benutzername zur Anmeldung - "wm#32", // Passwort - "emensawerbeseite" // Auswahl der Datenbanken (bzw. des Schemas) +"127.0.0.1", // Host der Datenbank +"root", // Benutzername zur Anmeldung +"admin", // Passwort +"emensawerbeseite" // Auswahl der Datenbanken (bzw. des Schemas) ); if (!$link) { @@ -24,18 +31,16 @@ if (!$link) { } //Besucher counter -if (file_exists("besucher.txt")) { - $besucherFile = fopen("besucher.txt", "r"); - $besucherCount = fgets($besucherFile) + 1; - fclose($besucherFile); - $besucherFile = fopen("besucher.txt", "w"); - fwrite($besucherFile, $besucherCount); - fclose($besucherFile); -} else { - $besucherFile = fopen("besucher.txt", "w"); - fwrite($besucherFile, 1); - fclose($besucherFile); -} + +//Aktuelle Besucher Zahl +$sql_besucher = "SELECT besucher FROM besucher_counter WHERE id=1"; +$result_sql_besucher = mysqli_query($link, $sql_besucher); +$besucher = mysqli_fetch_assoc($result_sql_besucher); + +//Updatet Besucher Zahl +$besucherCount = $besucher["besucher"] + 1; +$sql_besucher = "UPDATE besucher_counter SET besucher =".$besucherCount; +$result_sql_besucher = mysqli_query($link, $sql_besucher); //Newletter counter if (file_exists("newletter.txt")) { @@ -48,6 +53,7 @@ if (file_exists("newletter.txt")) { fclose($newsFile); } +//Newletter Anmeldung if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = $_POST['name']; $email = $_POST['email']; @@ -55,7 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $terms = $_POST['terms']; $errors = array(); - + //Error handling if (empty(trim($name))) { $errors[] = "Bitte geben Sie einen Namen ein."; } @@ -84,7 +90,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { "language" => $language, "terms" => $terms ); - + //File writing $file = "subscriptions.json"; $current_data = file_exists($file) ? json_decode(file_get_contents($file), true) : array(); $current_data[] = $data; @@ -249,6 +255,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {

Besuche

Anmeldungen zum Newsletter

-

Speisen

+

+ + Speisen +

Interesse geweckt? Wir informieren