# Datenbanken Abendkurs II
## Abfragen
**Autor:** John Doe
**Beschreibung:** Selektiert alles von `countries`.
~~~sql
select * from countries
~~~
---
**Autor:** Thomas Wessely
**Beschreibung:** ANTWORT #20 Die Abfrage gibt die Anzahl der gesprochenen Sprachen je Kontinent an.
~~~sql
select continents.name as Kontinent,
count(distinct country_languages.language_id) as Anzahl_der_Sprachen_pro_Kontinent
from continents
join regions
on continents.continent_id = regions.continent_id
join countries
on regions.region_id = countries.region_id
join country_languages
on countries.country_id = country_languages.country_id
group by continents.name;
~~~
**Autor:** Patrik
**Beschreibung:** Anwort auf die #20 der aufgabe #1
Diese Abfrage gibt die Top 10 Länder aus, basierend auf der Bevölkerung, die eine höhere Bevölkerungszahl als der Durchschnitt ihrer Bevölkerung der letzten 20 Jahre aufweisen.
~~~sql
SELECT c.name AS country,
cs.population AS population,
r.name AS region,
n.name AS continent
FROM nation.countries c
JOIN
nation.regions r ON c.region_id = r.region_id
JOIN
nation.continents n ON r.continent_id = n.continent_id
JOIN
nation.country_stats cs ON c.country_id = cs.country_id
WHERE cs.year > (SELECT MAX(year) FROM nation.country_stats WHERE country_id = c.country_id) - 20
AND cs.population > (SELECT AVG(population)
FROM nation.country_stats
WHERE country_id = c.country_id
AND year > (SELECT MAX(year) FROM nation.country_stats WHERE country_id = c.country_id) - 20)
ORDER BY cs.population DESC
LIMIT 10;
~~~
---
**Autor:** Stefan
**Beschreibung:** Select-Statement for specific value.
Select from Table Language where Language = 'German'.
~~~sql
SELECT language_id, language
FROM languages
WHERE language = 'German'
;
~~~
---
---
**Autor:** Kostadin Rizov
**Beschreibung:** Selektiert _ALLES_ von **countries** verknüpft mit **regions_area** wo **region_name** = _'Eastern Europe'_ und die **countries.region_id** = _'4'_ ist.
#### Kurzfassung
Gibt alle Länder aus, welche sich in Osteuropa befinden.
Die Attribut-Kombination aus _region_name = 'Eastern Europe'_ und _countries.region_id = 4_ begrenzt die Suche nur auf die gesuchte Region
~~~sql
SELECT * FROM countries JOIN region_areas WHERE region_name = 'Eastern Europe' && countries.region_id = 4;
~~~
## Abfrage aus Aufgabe 1:
~~~sql
SELECT c.country_id AS 'LänderID', c.name AS 'Ländername' , r.name AS 'Region', population AS 'Bevölkerungsanzahl', gdp AS 'GDP' FROM countries c
JOIN regions r on r.region_id = c.region_id
JOIN country_stats cs ON c.country_id = cs.country_id
WHERE cs.year = 2018 && r.region_id = 4 && cs.population BETWEEN 2070000 AND 2100000;
~~~
### _Ausgabe_:
| **LänderID** | **Ländername** | **Region** | **Bevölkerungsanzahl** | **GDP** |
| -------- | -------- | -------- | -------- | -------- |
| 138 | Macedonia | Southern Europe | 2082958 | 12672131053 |
- [ ] ← "Gefällt mir"-Button :)
---
---
**Autor:** Gumakow Ramazan
**Beschreibung:** Selektiert die ersten 10 Sprachen aus Language.
~~~sql
select language from languages limit 10;
~~~
---
**Autor:** Patrik Veliki
**Beschreibung:** Ziel der Abfrage ist es, die offizielle Sprache jedes Landes zu finden
~~~sql
# Ziel des queries ist es, die offizielle sprache jedes landes zu finden
SELECT countries.name AS country, # wähle die Länder nach name
languages.language AS official_language # wähle die Sprache
FROM countries # vom countries table
JOIN country_languages # join den country_languages table
ON countries.country_id = country_languages.country_id # join den country_languages table
AND country_languages.official = 1 # where official = 1
JOIN languages ON country_languages.language_id = languages.language_id # join den sprachen table
ORDER BY countries.name; # sortiere nach land name
~~~
---
**Autor:** Felix
**Beschreibung:** select all countries with the language 'German'.
~~~sql
select countries.name, continents.name from languages join
country_languages on languages.language_id = country_languages.language_id join
countries on country_languages.country_id = countries.country_id join
regions on regions.region_id = countries.region_id join
continents on continents.continent_id = regions.continent_id
where language = 'German';
~~~
---
**Autor:** Felix
**Beschreibung:** get the sum(population) of the continent 'Asia'.
~~~sql
select continents.name, sum(population) from country_stats join
countries on countries.country_id = country_stats.country_id join
regions on countries.region_id = regions.region_id join
continents on regions.continent_id = continents.continent_id
where continents.name = 'Asia' and country_stats.year = 2018;
~~~
---
**Autor:** Felix
**Beschreibung:** Gibt die gesamte Bevölkerung im deutschen Raum aus.
~~~sql
select sum(population) from countries join
country_languages on countries.country_id = country_languages.country_id join
languages on country_languages.language_id = languages.language_id join
country_stats on countries.country_id = country_stats.country_id
where country_languages.official = 1 and country_stats.year = 2018
and languages.language = 'German';
~~~
---
**Autor: Thomas Wessely**
**Beschreibung:** Selektiert den Ländercode2 und Ländercode3 aus dem Table countries für Österreich, Schweiz und Deutschland. Sortiert wird nach dem Ländernamen.
~~~sql
select
name,
country_code2,
country_code3
from
countries
where
country_code2 in ('AT','CH','DE')
&& country_code3 in ('AUT','CHE','DEU')
order by
name;
~~~
---
# Abfragen - Hilfestellungen
**Autor:** John Doe
**Beschreibung:** Selektiert alles von `countries`.
~~~sql
select * from countries
~~~
**Herausforderung:** Ich habe Ausgabe x möchte aber Ausgabe y.
### Lösung
**Autor:** Jane Doe
~~~sql
corrected query
~~~
---
**Autor:** Dzhambul Kazbekov
**Beschreibung:** Selektiert population vom Land Portugal von `countries` in `country_stats`
~~~sql
select country_stats.population
from countries
inner join country_stats using (country_id)
where countries.name='Portugal';
~~~
**Herausforderung:** Ich hätte gern die population vom Portugal, bekomme aber 59 Zeilen. HELP!
### Lösung
**Autor:** Felix Springer
Du musst im where country_stats.year hinzufügen
~~~sql
select country_stats.population from countries join
country_stats on countries.country_id = country_stats.country_id
where countries.name = 'Portugal' and country_stats.year = 2018;
~~~
DANKE FELIX!
___
# Das würde ich gerne lernen/wiederholen
**Autor:** Thomas Wessely
**Anfrage:**
- [x] Ein Mini Projekt wo wir eine Datenbank, Java für Backend und Javascript für Frontend benötigen. Wie kann man hier Schnittstellen erstellen bzw. wie kommunizieren diese Gemeinsam? Welche Datenbank wäre hier ratsam? Wie können hier Performant Daten übertragen werden?
**Antwort von Kostadin Rizov:**
Finde auch, dass das eine sehr gute Idee ist.
**Antwort von Patrik Veliki:**
Wäre auch dafür. =)
**Autor:** Felix
- [x] Netzwerktechnik (Grundlagen)
- [x] Kryptographie
- [x] subqueries
- [x] relational algebra
---
**Autor:** Kostadin "Koki" Rizov
***Anfrage:*** Einblick in AI
- Da AI ein künftig wichtiges Thema darstellt, finde ich eine "kleine" Einführung darin wie man mit AI arbeiten kann/soll, wäre ein nicer Punkt.
- mit Nice-To-Know-Topics
- und eventuell Nice-To-Have-Skills
***Interessierte Teilnehmer (bitte anklicken):***
- [x] Kostadin
- [x] Thomas
- [ ] Dzambhul
- [x] Jan
- [ ] Stefan
- [x] Natalia
- [ ] Ramazan
- [x] Magomed
- [ ] Felix
- [x] Patrik
---
# Weitere Datenbanksysteme
- https://ravendb.net/ Jan
- https://supabase.com/ Stefan
- https://www.cockroachlabs.com/ Natalia
- https://www.dolthub.com/ Magomed
- https://cassandra.apache.org/_/index.html Ramazan
- https://couchdb.apache.org/ Thomas
- https://neo4j.com/ Felix
- https://firebase.google.com/ Dzhambul
- https://www.couchbase.com/ ← Koki, und nur Koki!
- https://dgraph.io/ ← Patrik
- Eigene
## Präsentation Inhalt
Folgende Punkte müssen behandelt werden:
- Welche Datenbank
- Wie funktioniert sie. Art der Datenspeicherung
- Verwendungszweck
- Wer entwickelt sie
- Lizenz
- Anwendung
- Installation
- Wo läuft sie. Welches OS, welche Cloud.
- Wie funktionieren Statements.
- Welche Clients gibt es
- Demo
- Wie funktioniert eine Verbindung inklusive Statements in
- Java oder JavaScript oder C#
- Fazit
## Präsentation
Der Vortrag muss qualitativ Hochwertig sein. Keine überladenen Folien, keine Bilder mit schlechter Qulität.
**Wurden Bilder nicht selbst erstellet muss die Quelle angegeben werden.**
Die Folien und die Demo muss den anderen Teilnehmern zur Verfügung gestellt werden.
## Präsentations Tools
Nützliche Software um ansprechende Präsentationen erstellen zu können:
- https://marp.app/
- https://github.com/slidevjs/slidev
- https://latex-beamer.com/quick-start/
- https://www.google.com/slides/about/
- https://carbon.now.sh/
## Rahmenbedingunen
Die Präsentation kann auf Englisch oder Deutsch gehalten werden.
Präsentationszeit inklusive Livedemo 10 Minuten.
# Entwurfsmuster
Wähle eine Muster und stelle es vor. Die Programmiersprache darfst du selbst wählen.
https://refactoring.guru/
- Abstract Factory und Factory Stefan, Natalia
- Iterator Mago & Ramsy
- Memento Felix und Patrik
- Observer Thomas, Dhambul
- Flyweight Herr Cock und Jan