Question: SQL QUERIES HELP! CODE TO RUN: CREATE TABLE courses ( school VARCHAR(35), course VARCHAR(35), level INT, description TEXT, credits INT, PRIMARY KEY (school, course, level)
SQL QUERIES HELP!
CODE TO RUN:

CREATE TABLE courses ( school VARCHAR(35), course VARCHAR(35), level INT, description TEXT, credits INT, PRIMARY KEY (school, course, level) );
INSERT INTO courses VALUES ('French Academy','Croissants',1,'A terminal course in Croissant Construction',3), ('Italian Institute','Pasta',1,'Basic Pasta Shapes',3), ('Italian Institute','Pasta',2,'Intermediate Pasta Shapes',3), ('Italian Institute','Pasta',3,'Advanced Pasta Shapes',3), ('Bavarian College','Pretzels',1,'A terminal course in Pretzel Perfection',3);
CREATE TABLE offerings ( school VARCHAR(35), course VARCHAR(35), level INT, classdate DATE, location VARCHAR(35),
PRIMARY KEY (school, course, level, classdate), FOREIGN KEY (school, course, level) REFERENCES courses (school, course, level) );
INSERT INTO offerings VALUES ('French Academy','Croissants',1,'2021-11-19','Paris'), ('Italian Institute','Pasta',1,'2021-10-30','Milano'), ('Italian Institute','Pasta',2,'2021-10-30','Napoli'), ('Italian Institute','Pasta',3,'2021-10-30','Roma'), ('Italian Institute','Pasta',1,'2021-11-02','Firenze'), ('Italian Institute','Pasta',2,'2021-11-02','Genoa'), ('Italian Institute','Pasta',3,'2021-11-02','Venezia'), ('Bavarian College','Pretzels',1,'2021-12-01','Berlin'), ('Bavarian College','Pretzels',1,'2021-12-02','Hamburg'), ('Bavarian College','Pretzels',1,'2021-12-03','Munich'), ('Bavarian College','Pretzels',1,'2021-12-04','Berlin'), ('Bavarian College','Pretzels',1,'2021-12-05','Frankfurt');
CREATE TABLE students ( ssn INT, name VARCHAR(30), totalcredits INT,
PRIMARY KEY (ssn) );
INSERT INTO students VALUES (111,'john',24), (333,'amy',36);
CREATE TABLE staff ( ssn INT, name VARCHAR(30), job VARCHAR(20),
PRIMARY KEY (ssn) );
INSERT INTO staff VALUES (111,'john','chef'), (222,'mary','chef'), (444,'mark','assistant');
CREATE TABLE registrations ( ssn INT, school VARCHAR(35), course VARCHAR(35), level INT, classdate DATE, seatno INT,
PRIMARY KEY (ssn, school, course, level, classdate), FOREIGN KEY (ssn) REFERENCES students (ssn), FOREIGN KEY (school, course, level, classdate) REFERENCES offerings (school, course, level, classdate) );
INSERT INTO registrations VALUES (111,'French Academy','Croissants',1,'2021-11-19',2), (333,'Italian Institute','Pasta',1,'2021-10-30',15), (333,'Italian Institute','Pasta',2,'2021-10-30',15), (333,'Italian Institute','Pasta',3,'2021-10-30',15);
CREATE TABLE schedule ( ssn INT, school VARCHAR(35), course VARCHAR(35), level INT, classdate DATE, PRIMARY KEY (ssn, school, course, level, classdate), FOREIGN KEY (ssn) REFERENCES staff (ssn), FOREIGN KEY (school, course, level, classdate) REFERENCES offerings (school, course, level, classdate) );
INSERT INTO schedule VALUES (111,'Italian Institute','Pasta',1,'2021-10-30'), (111,'Italian Institute','Pasta',2,'2021-10-30'), (111,'Italian Institute','Pasta',3,'2021-10-30'), (222,'Italian Institute','Pasta',1,'2021-11-02'), (222,'Italian Institute','Pasta',2,'2021-11-02'), (222,'Italian Institute','Pasta',3,'2021-11-02'), (111,'Bavarian College','Pretzels',1,'2021-12-01'), (111,'Bavarian College','Pretzels',1,'2021-12-02'), (111,'Bavarian College','Pretzels',1,'2021-12-03'), (111,'Bavarian College','Pretzels',1,'2021-12-04'), (111,'Bavarian College','Pretzels',1,'2021-12-05'), (444,'Bavarian College','Pretzels',1,'2021-12-01'), (444,'Bavarian College','Pretzels',1,'2021-12-02'), (444,'Bavarian College','Pretzels',1,'2021-12-03'), (444,'Bavarian College','Pretzels',1,'2021-12-04'), (444,'Bavarian College','Pretzels',1,'2021-12-05');
Queries to be run: 1. Retrieve the names and jobs of all staff members. Order the results first by their job and then by their name (both ascending order). 2. Retrieve the total number of chefs currently in the database. 3. Retrieve the descriptions of all courses, without duplicates. 4. Retrieve the names of students that are registered for the 'Croissants' course offered by the 'French Academy' on November 19 , 2021. 5. Retrieve course offerings with no student registrations. 6. Retrieve course offerings where there are no staff members scheduled for that course. 7. Retrieve staff members who are chefs that teach courses in 'Berlin'. 8. Retrieve non-staff students and their expected credits based on current registrations. 9. Retrieve the names of staff that work (chef/assistant) on courses in Paris. 10. Retrieve the names of staff that never work in Paris
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
