This commit is contained in:
git-sandro 2026-02-13 15:27:24 +01:00
parent 0f3005cd8e
commit 522e144ca3
10 changed files with 115 additions and 1 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -19,4 +19,7 @@ GIT Repository for for the Module CDS-104
## GROUP BY
## HAVING
## HAVING
## JOIN

BIN
movies/.DS_Store vendored Normal file

Binary file not shown.

1
movies/order_by.sql Normal file
View File

@ -0,0 +1 @@
SELECT * FROM movies ORDER BY title DESC;

Binary file not shown.

21
murder_mystery/querys.sql Normal file
View File

@ -0,0 +1,21 @@
SELECT * FROM crime_scene_report WHERE city = 'SQL City' AND date = 20180115 AND type = 'murder';
-- Security footage shows that there were 2 witnesses. The first witness lives at the last house on "Northwestern Dr".
-- The second witness, named Annabel, lives somewhere on "Franklin Ave".
-- first witness
SELECT * FROM person WHERE address_street_name = 'Northwestern Dr' ORDER BY address_number DESC LIMIT 1;
-- id 14887 name Morty Schapiro license_id 118009 ssn 111564949
SELECT transcript FROM interview WHERE person_id = 14887;
-- I heard a gunshot and then saw a man run out. He had a "Get Fit Now Gym" bag. The membership number on the bag started with "48Z".
-- Only gold members have those bags. The man got into a car with a plate that included "H42W".
SELECT * FROM get_fit_now_member WHERE id LIKE '48Z%' AND membership_status = 'gold';
SELECT * FROM drivers_license WHERE plate_number LIKE '%H42W%';
-- second witness
SELECT * FROM person WHERE name LIKE '%Annabel%' AND address_street_name = 'Franklin Ave';
-- id 16371 name Annabel Miller license_id 490173 ssn 318771143
SELECT transcript FROM interview WHERE person_id = 16371;
-- I saw the murder happen, and I recognized the killer from my gym when I was working out last week on January the 9th.
SELECT * FROM get_fit_now_check_in WHERE check_in_date = 20180109 AND membership_id LIKE '48Z%'

BIN
normalformen/Übung_NF.xlsx Normal file

Binary file not shown.

59
shop/ctreate_table.sql Normal file
View File

@ -0,0 +1,59 @@
/*CREATE TABLE kunde
(
id SERIAL PRIMARY KEY,
vorname CHARACTER VARYING NOT NULL,
name CHARACTER VARYING NOT NULL,
email CHARACTER VARYING NOT NULL,
passwort CHARACTER VARYING NOT NULL
);
CREATE TABLE bestellung
(
id SERIAL PRIMARY KEY,
datum DATE
);
CREATE TABLE bestellposition
(
bestellung_id INTEGER,
produkt_id INTEGER,
anzahl INTEGER
);
CREATE TABLE produkte
(
id SERIAL PRIMARY KEY,
name CHARACTER VARYING NOT NULL,
beschreibung CHARACTER VARYING NOT NULL,
preis NUMERIC(8,2) NOT NULL,
lagerbestand INTEGER NOT NULL
);*/
CREATE TABLE kunde
(
id INTEGER PRIMARY KEY,
name CHARACTER VARYING NOT NULL,
email CHARACTER VARYING NOT NULL,
password CHARACTER VARYING NOT NULL
);
CREATE TABLE bestellung
(
id INTEGER PRIMARY KEY,
kunde_id INTEGER NOT NULL,
datum DATE NOT NULL
);
CREATE TABLE produkt
(
id INTEGER PRIMARY KEY,
name CHARACTER VARYING NOT NULL,
beschreibung CHARACTER VARYING NOT NULL,
anzahl INTEGER NOT NULL,
preis NUMERIC(8,2) NOT NULL
);
CREATE TABLE bestellung_produkt
(
bestellung_id INTEGER NOT NULL,
produkt_id INTEGER NOT NULL,
anzahl INTEGER NOT NULL
);

20
shop/insert.sql Normal file
View File

@ -0,0 +1,20 @@
INSERT INTO kunde VALUES
(1, 'Ingmar', 'ingmar@example.com', 'FN239v_d32%nsej3'),
(3, 'Maria', 'maria@example.com', 'abc_%&'),
(4, 'John', 'john@example.com', 'KeepCalm'),
(2, 'Peter', 'peter@example.com', 'lskdfjlskdfj');
INSERT INTO produkt VALUES
(1, 'Keyboard', 'QUERTZ', 12, 29.99),
(2, 'Notebook', 'Standard', 1, 1299.00),
(3, 'Monitor', 'Flat', 5, 389.90),
(4, 'Maus', 'Kabellos', 2, 19.00);
INSERT INTO bestellung VALUES
(1, 1, '2022-01-03'),
(2, 1, '2022-01-07'),
(3, 2, '2022-01-09');
INSERT INTO bestellung_produkt VALUES
(1, 1, 2),
(1, 2, 1),
(2, 3, 4),
(3, 2, 2),
(3, 4, 1);

10
shop/join.sql Normal file
View File

@ -0,0 +1,10 @@
SELECT bestellung.id, kunde.name
FROM bestellung
JOIN kunde ON kunde.id = bestellung.kunde_id;
SELECT produkt.id, produkt.name, bestellung_produkt.anzahl
FROM produkt
JOIN bestellung_produkt ON produkt.id = bestellung_produkt.bestellung_id;
SELECT * FROM bestellung, produkt
JOIN bestellung_produkt on bestellung.id = bestellung_produkt.bestellung_id;