0% found this document useful (0 votes)
2 views

SQL- Practice Problem4

The document outlines a practice problem for a Database Systems course at the National University of Computer and Emerging Sciences, focusing on SQL queries. It includes two sets of relations, EMP and DEPT, as well as Computer, Model, and Maker schemas, with specific SQL query tasks related to employee salaries, department budgets, and computer models. The queries require students to utilize foreign keys and aggregate functions to retrieve data based on given conditions.

Uploaded by

tfaizanvr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL- Practice Problem4

The document outlines a practice problem for a Database Systems course at the National University of Computer and Emerging Sciences, focusing on SQL queries. It includes two sets of relations, EMP and DEPT, as well as Computer, Model, and Maker schemas, with specific SQL query tasks related to employee salaries, department budgets, and computer models. The queries require students to utilize foreign keys and aggregate functions to retrieve data based on given conditions.

Uploaded by

tfaizanvr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

National University of Computer and Emerging Sciences, Lahore Campus

Course: Database Systems


Program: BS(Computer Science)
Instructor: Muhammad Ishaq Raza

Practice Problem: SQL (4)

Question 1: Use the two relations given below to write the following queries in SQL:
EMP (SSN, FirstName, LastName, Title, Salary, DeptId, MgrId)
DEPT (Did, DepartmentName, TotalBudget)

Foreign Keys: DeptId references DEPT.Did and MgrId references EMP.SSN

1. Find the name, total budget of departments in which the total salary of all people working in that department
exceeds the total budget of the department.
2. Find the first and last name of employees whose salary is greater than the salary of their manager.
3. Find name of departments that does not have any employees with title ”Vice President” working in them.

Question 2: Consider the following database schema of computer products:


Computer (maker, model, category)
Model (num, speed, ram, hd, price)
Maker (name, address, phone)
Where
• maker indicates the manufacturer of the computer;
• category takes values such as ‘desktop’, ‘laptop’, ‘server’;
• maker and model attributes are foreign keys;

Express following queries in SQL:


1. Find all the makers who make at most one model or don’t make any model.
2. Find all desktop models with the highest speed, and return them along with their makers.
3. Display maker, model_count of all the makers who make at least three different desktop models.

Page 1 of 1

You might also like