diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/lab-java-normalization-ddl-aggregation.iml b/.idea/lab-java-normalization-ddl-aggregation.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/lab-java-normalization-ddl-aggregation.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f5bd2df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..152076a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/normalizationLab.sql b/normalizationLab.sql new file mode 100644 index 0000000..c8a97e3 --- /dev/null +++ b/normalizationLab.sql @@ -0,0 +1,48 @@ +USE normalization_lab; + +SELECT COUNT(DISTINCT flight_number) AS total_flights +FROM flights; + +SELECT AVG(mileage) AS avg_flight_distance +FROM flights; + +SELECT AVG(total_seats) AS avg_seats +FROM aircrafts; + +SELECT status, AVG(total_mileage) AS avg_customer_mileage +FROM customers +GROUP BY status; + +SELECT status, MAX(total_mileage) AS max_customer_mileage +FROM customers +GROUP BY status; + +SELECT COUNT(*) AS boeing_aircraft_count +FROM aircrafts +WHERE name LIKE '%Boeing%'; + +SELECT * +FROM flights +WHERE mileage BETWEEN 300 AND 2000; + +SELECT c.status, AVG(f.mileage) AS avg_booked_flight_distance +FROM bookings b +JOIN customers c ON b.customer_id = c.id +JOIN flights f ON b.flight_number = f.flight_number +GROUP BY c.status; + +SELECT a.name, COUNT(*) AS total_bookings +FROM bookings b +JOIN customers c ON b.customer_id = c.id +JOIN flights f ON b.flight_number = f.flight_number +JOIN aircrafts a ON f.aircraft_id = a.id +WHERE c.status = 'Gold' +GROUP BY a.name +ORDER BY total_bookings DESC +LIMIT 1; + + + + + +