SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Downloaden Sie, um offline zu lesen
SQL Query Assignment
Submission Way: A hard copy written by hand has to be submitted.

Due: Two weeks

Part 1:

1.0 The Database
This assignment will use a database containing university-type data. The relations are contained
in a database called test. The schema of the database is provided below (keys are in bold).
 

student (sid, sname, sex, age, year, gpa)
dept(dname, numphds)
prof(pname, dname)
course(cno, cname, dname)
major(dname, sid)
section(dname, cno, sectno, pname)
enroll(sid, grade, dname, cno, sectno)


 Queries
Write SQL queries and relational algebraic expression (assume only basic operations are
available) that answer the questions below (one query/expression per question) and run them on
the MYSQL system. The query answers should be duplicate free, but you should use
distinct only when necessary.

   1. Print the names of professors who work in departments that have fewer than 50 PhD
       students.
   2. Print the name(s) of student(s) with the lowest gpa.
   3. For each Computer Sciences class, print the cno, sectno, and the average gpa of the
       students enrolled in the class.
   4. Print the names and section numbers of all classes with more than six students enrolled
       in them.
   5. Print the name(s) and sid(s) of the student(s) enrolled in the most classes.
   6. Print the names of departments that have one or more majors who are under 18 years old.
   7. Print the names and majors of students who are taking one of the College Geometry
       courses. (You’ll need to use the quot;likequot; predicate and the string matching character in your
       query.)
   8. For those departments that have no majors taking a College Geometry course, print the
       department name and the number of PhD students in the department.
   9. Print the names of students who are taking both a Computer Sciences course and a
       Mathematics course.
   10. Print the age difference between the oldest and youngest Computer Sciences major(s).
   11. For each department that has one or more majors with a GPA under 1.0, print the name
       of the department and the average GPA of its majors.
12. Print the ids, names, and GPAs of the students who are currently taking all of the Civil
Engineering courses.

Part 2:

Consider a relational schema Employee(empID,bonus), where empID is a key. Do you think the
following two queries are always equivalent, i.e., do they yield the same result on all possible
databases?

  SELECT AVG(bonus) FROM Employee


  SELECT SUM(bonus)/COUNT(*) FROM Employee

If you think they are always equivalent, justify your answer. If you think they are not always
equivalent, give the simplest example data for Employee you can think of for which you expect
the two queries to yield different results. 

Part 3:  

Consider a relation Flight(city1, city2, cost, airline) containing nonstop flights from one city to
another. We were interested in a single SQL query that would return the cheapest cost of flying
between each pair of cities, regardless of the number of stops. While you may have had difficulty
writing such a query in SQL2, it is possible to compute the answer using SQL in conjunction
with a programming language, and that's your task in this problem. You may use SQL embedded
within a C-like language or you may use a PL/SQL-like syntax, or you may use CLI/JDBC-style
dynamic SQL for this assignment. Please use MYSQL database for this assignment.



Submission Way: A hard copy written by hand has to be submitted.

Weitere ähnliche Inhalte

Was ist angesagt?

What is e.rc diagram
What is e.rc diagramWhat is e.rc diagram
What is e.rc diagramanswersheet
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersAbdul Rahman Sherzad
 
DBMS Question bank
DBMS Question bankDBMS Question bank
DBMS Question bankSara Sahu
 
Introduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete MathematicsIntroduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete Mathematicsblaircomp2003
 
Reality of education system after 12th engineering admission myth
Reality of education system after 12th engineering admission mythReality of education system after 12th engineering admission myth
Reality of education system after 12th engineering admission mythKalyan Ranjan
 
Application of discrete mathematics in IT
Application of discrete mathematics in ITApplication of discrete mathematics in IT
Application of discrete mathematics in ITShahidAbbas52
 
Database Q&A
Database  Q&ADatabase  Q&A
Database Q&Aeduafo
 
Structures in c language
Structures in c languageStructures in c language
Structures in c languagetanmaymodi4
 
Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Severus Prime
 
Quiz3midterm
Quiz3midtermQuiz3midterm
Quiz3midtermlearnt
 
Differential Equetion presentation
Differential Equetion presentationDifferential Equetion presentation
Differential Equetion presentationJholok Biswash
 
Application of integration in real life.
Application of integration in real life.Application of integration in real life.
Application of integration in real life.Jholok Biswash
 
Chapter 2 part 1(Database System)
Chapter 2 part 1(Database System)Chapter 2 part 1(Database System)
Chapter 2 part 1(Database System)DoLce MiEra
 
Pemrograman komputer 4 (ekspresi)
Pemrograman komputer  4 (ekspresi)Pemrograman komputer  4 (ekspresi)
Pemrograman komputer 4 (ekspresi)jayamartha
 

Was ist angesagt? (20)

Describe b2 b.
Describe b2 b.Describe b2 b.
Describe b2 b.
 
What is e.rc diagram
What is e.rc diagramWhat is e.rc diagram
What is e.rc diagram
 
Need for erp.
Need for erp.Need for erp.
Need for erp.
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
 
Cs8391 notes rejinpaul
Cs8391 notes rejinpaulCs8391 notes rejinpaul
Cs8391 notes rejinpaul
 
DBMS Question bank
DBMS Question bankDBMS Question bank
DBMS Question bank
 
Introduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete MathematicsIntroduction and Applications of Discrete Mathematics
Introduction and Applications of Discrete Mathematics
 
Reality of education system after 12th engineering admission myth
Reality of education system after 12th engineering admission mythReality of education system after 12th engineering admission myth
Reality of education system after 12th engineering admission myth
 
Application of discrete mathematics in IT
Application of discrete mathematics in ITApplication of discrete mathematics in IT
Application of discrete mathematics in IT
 
Database Q&A
Database  Q&ADatabase  Q&A
Database Q&A
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System Math Editing and display using Microsoft Office 2007 System
Math Editing and display using Microsoft Office 2007 System
 
What is Discrete Mathematics?
What is Discrete Mathematics?What is Discrete Mathematics?
What is Discrete Mathematics?
 
Quiz3midterm
Quiz3midtermQuiz3midterm
Quiz3midterm
 
Differential Equetion presentation
Differential Equetion presentationDifferential Equetion presentation
Differential Equetion presentation
 
Structure in C
Structure in CStructure in C
Structure in C
 
Application of integration in real life.
Application of integration in real life.Application of integration in real life.
Application of integration in real life.
 
Chapter 2 part 1(Database System)
Chapter 2 part 1(Database System)Chapter 2 part 1(Database System)
Chapter 2 part 1(Database System)
 
Req
ReqReq
Req
 
Pemrograman komputer 4 (ekspresi)
Pemrograman komputer  4 (ekspresi)Pemrograman komputer  4 (ekspresi)
Pemrograman komputer 4 (ekspresi)
 

Ähnlich wie Assignment2

MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSARVIND SARDAR
 
INF 103(ASH) Possible Is Everything/newtonhelp.com
INF 103(ASH) Possible Is Everything/newtonhelp.comINF 103(ASH) Possible Is Everything/newtonhelp.com
INF 103(ASH) Possible Is Everything/newtonhelp.comlechenau71
 
INF 103(ASH) Learn/newtonhelp.com
INF 103(ASH) Learn/newtonhelp.comINF 103(ASH) Learn/newtonhelp.com
INF 103(ASH) Learn/newtonhelp.comlechenau48
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment mejoney4
 
INF 103 Education Specialist / snaptutorial.com
INF 103 Education Specialist / snaptutorial.comINF 103 Education Specialist / snaptutorial.com
INF 103 Education Specialist / snaptutorial.comMcdonaldRyan94
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3Kuntal Bhowmick
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3Kuntal Bhowmick
 
Bc0053 – vb.net & xml
Bc0053 – vb.net & xmlBc0053 – vb.net & xml
Bc0053 – vb.net & xmlsmumbahelp
 
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILERRANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILERijseajournal
 
INF 103 Exceptional Education - snaptutorial.com
INF 103  Exceptional Education - snaptutorial.comINF 103  Exceptional Education - snaptutorial.com
INF 103 Exceptional Education - snaptutorial.comDavisMurphyB9
 
INF 103 Effective Communication - snaptutorial.com
INF 103 Effective Communication - snaptutorial.comINF 103 Effective Communication - snaptutorial.com
INF 103 Effective Communication - snaptutorial.comdonaldzs22
 
Inf 103 Education Organization-snaptutorial.com
Inf 103 Education Organization-snaptutorial.comInf 103 Education Organization-snaptutorial.com
Inf 103 Education Organization-snaptutorial.comrobertlesew19
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3iARVIND SARDAR
 
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxDIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxlynettearnold46882
 
CSC388 Online Programming Languages Homework 3 (due b.docx
CSC388 Online Programming Languages  Homework 3 (due b.docxCSC388 Online Programming Languages  Homework 3 (due b.docx
CSC388 Online Programming Languages Homework 3 (due b.docxannettsparrow
 
Inf 103 Enhance teaching / snaptutorial.com
Inf 103 Enhance teaching / snaptutorial.comInf 103 Enhance teaching / snaptutorial.com
Inf 103 Enhance teaching / snaptutorial.comBaileya16
 
INF 103 Effective Communication/tutorialrank.com
 INF 103 Effective Communication/tutorialrank.com INF 103 Effective Communication/tutorialrank.com
INF 103 Effective Communication/tutorialrank.comjonhson291
 
Building data fusion surrogate models for spacecraft aerodynamic problems wit...
Building data fusion surrogate models for spacecraft aerodynamic problems wit...Building data fusion surrogate models for spacecraft aerodynamic problems wit...
Building data fusion surrogate models for spacecraft aerodynamic problems wit...Shinwoo Jang
 
2005 fall cs523_lecture_4
2005 fall cs523_lecture_42005 fall cs523_lecture_4
2005 fall cs523_lecture_4abhineetverma
 

Ähnlich wie Assignment2 (20)

MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMS
 
INF 103(ASH) Possible Is Everything/newtonhelp.com
INF 103(ASH) Possible Is Everything/newtonhelp.comINF 103(ASH) Possible Is Everything/newtonhelp.com
INF 103(ASH) Possible Is Everything/newtonhelp.com
 
INF 103(ASH) Learn/newtonhelp.com
INF 103(ASH) Learn/newtonhelp.comINF 103(ASH) Learn/newtonhelp.com
INF 103(ASH) Learn/newtonhelp.com
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment me
 
INF 103 Education Specialist / snaptutorial.com
INF 103 Education Specialist / snaptutorial.comINF 103 Education Specialist / snaptutorial.com
INF 103 Education Specialist / snaptutorial.com
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3
 
Ee java lab assignment 3
Ee java lab assignment 3Ee java lab assignment 3
Ee java lab assignment 3
 
Bc0053 – vb.net & xml
Bc0053 – vb.net & xmlBc0053 – vb.net & xml
Bc0053 – vb.net & xml
 
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILERRANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
RANDOM TESTS COMBINING MATHEMATICA PACKAGE AND LATEX COMPILER
 
Project3
Project3Project3
Project3
 
INF 103 Exceptional Education - snaptutorial.com
INF 103  Exceptional Education - snaptutorial.comINF 103  Exceptional Education - snaptutorial.com
INF 103 Exceptional Education - snaptutorial.com
 
INF 103 Effective Communication - snaptutorial.com
INF 103 Effective Communication - snaptutorial.comINF 103 Effective Communication - snaptutorial.com
INF 103 Effective Communication - snaptutorial.com
 
Inf 103 Education Organization-snaptutorial.com
Inf 103 Education Organization-snaptutorial.comInf 103 Education Organization-snaptutorial.com
Inf 103 Education Organization-snaptutorial.com
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
 
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docxDIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
DIRECTIONS READ THE FOLLOWING STUDENT POST AND RESPOND EVALUATE I.docx
 
CSC388 Online Programming Languages Homework 3 (due b.docx
CSC388 Online Programming Languages  Homework 3 (due b.docxCSC388 Online Programming Languages  Homework 3 (due b.docx
CSC388 Online Programming Languages Homework 3 (due b.docx
 
Inf 103 Enhance teaching / snaptutorial.com
Inf 103 Enhance teaching / snaptutorial.comInf 103 Enhance teaching / snaptutorial.com
Inf 103 Enhance teaching / snaptutorial.com
 
INF 103 Effective Communication/tutorialrank.com
 INF 103 Effective Communication/tutorialrank.com INF 103 Effective Communication/tutorialrank.com
INF 103 Effective Communication/tutorialrank.com
 
Building data fusion surrogate models for spacecraft aerodynamic problems wit...
Building data fusion surrogate models for spacecraft aerodynamic problems wit...Building data fusion surrogate models for spacecraft aerodynamic problems wit...
Building data fusion surrogate models for spacecraft aerodynamic problems wit...
 
2005 fall cs523_lecture_4
2005 fall cs523_lecture_42005 fall cs523_lecture_4
2005 fall cs523_lecture_4
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Assignment2

  • 1. SQL Query Assignment Submission Way: A hard copy written by hand has to be submitted. Due: Two weeks Part 1: 1.0 The Database This assignment will use a database containing university-type data. The relations are contained in a database called test. The schema of the database is provided below (keys are in bold).   student (sid, sname, sex, age, year, gpa) dept(dname, numphds) prof(pname, dname) course(cno, cname, dname) major(dname, sid) section(dname, cno, sectno, pname) enroll(sid, grade, dname, cno, sectno) Queries Write SQL queries and relational algebraic expression (assume only basic operations are available) that answer the questions below (one query/expression per question) and run them on the MYSQL system. The query answers should be duplicate free, but you should use distinct only when necessary. 1. Print the names of professors who work in departments that have fewer than 50 PhD students. 2. Print the name(s) of student(s) with the lowest gpa. 3. For each Computer Sciences class, print the cno, sectno, and the average gpa of the students enrolled in the class. 4. Print the names and section numbers of all classes with more than six students enrolled in them. 5. Print the name(s) and sid(s) of the student(s) enrolled in the most classes. 6. Print the names of departments that have one or more majors who are under 18 years old. 7. Print the names and majors of students who are taking one of the College Geometry courses. (You’ll need to use the quot;likequot; predicate and the string matching character in your query.) 8. For those departments that have no majors taking a College Geometry course, print the department name and the number of PhD students in the department. 9. Print the names of students who are taking both a Computer Sciences course and a Mathematics course. 10. Print the age difference between the oldest and youngest Computer Sciences major(s). 11. For each department that has one or more majors with a GPA under 1.0, print the name of the department and the average GPA of its majors.
  • 2. 12. Print the ids, names, and GPAs of the students who are currently taking all of the Civil Engineering courses. Part 2: Consider a relational schema Employee(empID,bonus), where empID is a key. Do you think the following two queries are always equivalent, i.e., do they yield the same result on all possible databases? SELECT AVG(bonus) FROM Employee SELECT SUM(bonus)/COUNT(*) FROM Employee If you think they are always equivalent, justify your answer. If you think they are not always equivalent, give the simplest example data for Employee you can think of for which you expect the two queries to yield different results.  Part 3:   Consider a relation Flight(city1, city2, cost, airline) containing nonstop flights from one city to another. We were interested in a single SQL query that would return the cheapest cost of flying between each pair of cities, regardless of the number of stops. While you may have had difficulty writing such a query in SQL2, it is possible to compute the answer using SQL in conjunction with a programming language, and that's your task in this problem. You may use SQL embedded within a C-like language or you may use a PL/SQL-like syntax, or you may use CLI/JDBC-style dynamic SQL for this assignment. Please use MYSQL database for this assignment. Submission Way: A hard copy written by hand has to be submitted.