Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added src folder and organized project structure with package com.ren… #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/lab-java-sql.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions main/resources/sql/airline_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY AUTO_INCREMENT,
CustomerName VARCHAR(100) NOT NULL,
CustomerStatus VARCHAR(50)
);

CREATE TABLE Flights (
FlightNumber VARCHAR(10) PRIMARY KEY,
Aircraft VARCHAR(100),
TotalAircraftSeats INT,
FlightMileage INT
);

CREATE TABLE CustomerFlights (
CustomerID INT,
FlightNumber VARCHAR(10),
TotalCustomerMileage INT,
PRIMARY KEY (CustomerID, FlightNumber),
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID),
FOREIGN KEY (FlightNumber) REFERENCES Flights(FlightNumber)
);

INSERT INTO Customers (CustomerName, CustomerStatus) VALUES
('Agustine Riviera', 'Silver'),
('Alaina Sepulvida', 'None'),
('Tom Jones', 'Gold'),
('Sam Rio', 'None'),
('Jessica James', 'Silver'),
('Ana Janco', 'Silver'),
('Jennifer Cortez', 'Gold'),
('Christian Janco', 'Silver');

INSERT INTO Flights (FlightNumber, Aircraft, TotalAircraftSeats, FlightMileage) VALUES
('DL143', 'Boeing 747', 400, 135),
('DL122', 'Airbus A330', 236, 4370),
('DL53', 'Boeing 777', 264, 2078),
('DL222', 'Boeing 777', 264, 1765),
('DL37', 'Boeing 747', 400, 531);

INSERT INTO CustomerFlights (CustomerID, FlightNumber, TotalCustomerMileage) VALUES
(1, 'DL143', 115235),
(1, 'DL122', 115235),
(2, 'DL122', 6008),
(3, 'DL122', 205767),
(3, 'DL53', 205767),
(4, 'DL143', 2653),
(5, 'DL143', 127656),
(5, 'DL122', 127656),
(6, 'DL222', 136773),
(7, 'DL222', 300582),
(8, 'DL222', 14642),
(4, 'DL37', 2653);
2 changes: 2 additions & 0 deletions main/resources/sql/average_flight_distance.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT AVG(FlightMileage) AS AverageFlightDistance
FROM Flights;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT CustomerStatus, AVG(FlightMileage) AS AverageFlightDistance
FROM Customers
JOIN CustomerFlights ON Customers.CustomerID = CustomerFlights.CustomerID
JOIN Flights ON CustomerFlights.FlightNumber = Flights.FlightNumber
GROUP BY CustomerStatus;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT CustomerStatus, AVG(TotalCustomerMileage) AS AverageMilesFlown
FROM Customers
JOIN CustomerFlights ON Customers.CustomerID = CustomerFlights.CustomerID
GROUP BY CustomerStatus;
2 changes: 2 additions & 0 deletions main/resources/sql/average_number_of_seats.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT AVG(TotalAircraftSeats) AS AverageNumberOfSeats
FROM Flights;
24 changes: 24 additions & 0 deletions main/resources/sql/blog_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE TABLE Authors (
AuthorID INT PRIMARY KEY AUTO_INCREMENT,
AuthorName VARCHAR(100) NOT NULL
);

CREATE TABLE Blogs (
BlogID INT PRIMARY KEY AUTO_INCREMENT,
AuthorID INT,
Title VARCHAR(255) NOT NULL,
WordCount INT,
Views INT,
FOREIGN KEY (AuthorID) REFERENCES Authors(AuthorID)
);

INSERT INTO Authors (AuthorName) VALUES ('Maria Charlotte'), ('Juan Perez'), ('Gemma Alcocer');

INSERT INTO Blogs (AuthorID, Title, WordCount, Views) VALUES
(1, 'Best Paint Colors', 814, 14),
(2, 'Small Space Decorating Tips', 1146, 221),
(1, 'Hot Accessories', 986, 105),
(1, 'Mixing Textures', 765, 22),
(2, 'Kitchen Refresh', 1242, 307),
(1, 'Homemade Art Hacks', 1002, 193),
(3, 'Refinishing Wood Floors', 1571, 7542);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT *
FROM Flights
WHERE FlightMileage BETWEEN 300 AND 2000;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT CustomerStatus, MAX(TotalCustomerMileage) AS MaximumMilesFlown
FROM Customers
JOIN CustomerFlights ON Customers.CustomerID = CustomerFlights.CustomerID
GROUP BY CustomerStatus;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT Aircraft, COUNT(*) AS Bookings
FROM Customers
JOIN CustomerFlights ON Customers.CustomerID = CustomerFlights.CustomerID
JOIN Flights ON CustomerFlights.FlightNumber = Flights.FlightNumber
WHERE CustomerStatus = 'Gold'
GROUP BY Aircraft
ORDER BY Bookings DESC
LIMIT 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT COUNT(*) AS TotalBoeingAircraft
FROM Flights
WHERE Aircraft LIKE '%Boeing%';
2 changes: 2 additions & 0 deletions main/resources/sql/total_number_of_flights.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT COUNT(*) AS TotalFlights
FROM Flights;
4 changes: 4 additions & 0 deletions src/com/renereyes/sql/main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.renereyes.sql;

public class main {
}