Consider the University database: 1\. For each department list the department code and the largest value for credit hours. 2\. For each department list the department code, department name, and the number of courses.

Short Answer

Expert verified
In order to solve the exercise, two different queries must be executed. The first query using the MAX function to find the department with the maximum credit hours, and the second one using the COUNT function to determine the number of courses in each department.

Step by step solution

01

Understanding problem and Preparing for Solution

Here we are dealing with a relational database where there's probably a Department and a Course table and are somehow related. We assume that the Department table has columns including department_code and department_name. The Course table likely includes columns such as department_code and credit_hours, among others. With this understanding, we can begin solving the exercise
02

- Query for Maximum Credit Hours

To find the department_code along with the highest value for credit_hours among the courses offered by each department, we can use the MAX() aggregate function in the query. It would look like this: SELECT department_code, MAX(credit_hours) AS max_credit_hours FROM Course GROUP BY department_code ;
03

- Query for Number of Courses

For finding the department_code, department_name, and the number of courses offered by each department, we must use the COUNT() function. Here, we can use INNER JOIN to fetch data from multiple tables. The query would look like this: SELECT d.department_code, d.department_name, COUNT(c.course_id) AS num_coursesFROM Department d INNER JOIN Course c ON d.department_code = c.department_code GROUP BY d.department_code, d.department_name ;

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Consider the Library database. 1\. Write a query to list books due on a specific date (a parameter). 2\. Write a query to list books written by a specific author (a parameter).

Consider the University database. 1\. Create a query to list all courses in a department (for which the user supplies the department code). 2\. Create a query to list all course titles where the user supplies both the department code and the credit hours. Note that two separate criteria, each with their own parameter, must be specified.

Consider the Sales database and its Store and Product tables. Construct a query to list the storeID and the productID. When you add Store and Product to the relationships area there is a line joining the two tables. Delete the join line. Run the query. Notice how many rows there are; the number of rows in the result set is the number of stores times the number of products.Exercise \(6.8 .1\)

Consider the Company database and its Employee table. 1\. The empId field is assigned values sequentially starting at 1. What is the last empId value that was used? (What is the empId for the last employee added to the table?) 2\. Write a query to determine the name of the oldest employee. 3\. Write a query to list all of the employee last names. If at least two employees have the same last name then this list will be shorter that a list of employees. 4\. Suppose there is a field hireDate which holds the date when an employee was hired. Write a query to determine the name of the employee who was most recently hired?

Consider the library database. 1\. Create a query that will list every book and the date it was borrowed. Include all books in your result. 2\. Create a query to list every library member and the dates they borrowed books. Include all members 3\. Try creating a query that will list books that have never been borrowed. 4\. Try creating a query to list any members who have not borrowed a book.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free