Spring_2024_Midterm_Exam

docx

School

Hudson County Community College *

*We aren’t endorsed by this school

Course

2022

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by DeanMetal13459

Report
Name: _______ CS561 WS Midterm Exam Given that this exam is about testing your knowledge of those aspects of SQL that were discussed in the lectures, no operations that weren’t discussed may be used. For example, JOIN and any variation of JOIN may not be used. All questions relate to the AIRLINE database. (Listed Under “5 Airline Database Schema.pdf in Week 1 Modules) The exam must be submitted as either a Word or a PPT document, No handwritten inclusions will be accepted. 1. (5 pts) Construct an instance of LEG_INSTANCE that violates the table’s key constraint, and explain why/how it violates the key constraint. 2. (5 pts) Construct instances of the CAN_LAND and AIRPORT tables that violate the foreign key reference from CAN_LAND to AIRPORT, and explain why/how they violate the key constraint. 3. (10 pts) Write the following query in the pseudo-code used in the lectures: Find every flight that lands in at least three airports 4. (10 pts) Write the following query in unextended relational algebra: Find every flight that lands in the maximum number of airports that any flight lands in 5. (10 pts) Write the following query in extended relational algebra: Find the total of the number of seats in all flights that land in Newark, NJ (EWR) 6. (10 pts) Write the following query in SQL, without any embedded queries: Find every flight that takes off on Sundays
7. Consider the following query: Find all airports that are not currently used as a destination for any flights. a. (10 points) Write the query in SQL with an embedded query that uses either IN or NOT IN, whichever is appropriate. (You may not use EXISTS or NOT EXISTS). b. (10 points) Write the query in SQL using an embedded query that uses either EXISTS or NOT EXISTS, whichever is appropriate. (You may not use IN or NOT IN). 8. (10 points) Write the following query in SQL using both a GROUP BY and a HAVING clause. (You may not use any of the following operators: IN, NOT IN, EXISTS, NOT EXISTS, <rel op> ALL, <rel op> ANY, <rel op SOME>) Find the total number of flights from each airline that departs on Sundays. 9. (10 pts) Write a SQL query to find the average number of available seats on flights that depart from airports located in California. 10. (10 pts) Write a query in unextended relational algebra to find the flight number(s) with the highest number of available seats.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help