0% found this document useful (0 votes)
28 views2 pages

DA 512H - Databases Assignment 1: Ashok@iitg Chiranjib@iitg

Uploaded by

apoorvakumari75
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)
28 views2 pages

DA 512H - Databases Assignment 1: Ashok@iitg Chiranjib@iitg

Uploaded by

apoorvakumari75
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/ 2

DA 512H - Databases

Assignment 1

Instructor: Prof. Ashok Singh Sairam Time: Monday - 10:00-10:55 (1004)


and Tuesday - 11:00-12:55 (1004)
Dr. Chiranjib Sur Friday - 9:00-9:55 (1004)
Email: ashok@iitg, chiranjib@iitg Place: 1004.

Problem 1: Relational Algebra and SQL [5 marks each]


Consider the following relational schema:

Emp(eid:integer, ename:string, age:integer, salary:real)


Works(eid:integer, did:integer, pct time:integer)
Dept(did:integer, dname:string, budget:real, managerid:integer)

An employee can work in more than one department; the pct time field of the ‘Works’ relation shows the
percentage of time that a given employee works in a given department. Managers are not employees of any
department.

Write the following queries in relational algebra and SQL:

1. Print the name and the age of each employee who works in both Hardware and Software departments.

2. For each employee, print the names of all its managers.

3. For each manager that is at most 40 years old, print its name and its salary.

4. Print the name of all managers that manage more than one department.

5. Print the name of all employees that work exactly in one department.

6. Print the name and the number of departments each employee works in.

7. For each department with more than 20 full-time-equivalent employees (i.e., where the part-time and
full-time employees add up to at least that many full-time employees), print the did together with the
number of employees that work in that department.

8. Find the ename of the manager who manages the department with the largest budget.

9. Find the ename of managers who manage only departments with budgets larger than $1 million, but
at least one department with budget less than $5 million.

Problem 2: Database Modifications and Constraints [5 marks each]


Consider the schema in the previous problem. To define constraints, you have to give the SQL code that
specifies both the schema and the constraints.

1. Define a constraint on Emp that will ensure that every employee makes at least $10, 000. What kind
of constraint is it (attribute or table)?

page 1 of 2
Course Name November 13, 2023

2. What are the foreign-key constraints that can be specified on the schema. Give the SQL code that
specifies the constraints.

3. Write SQL statements to delete all information about employees whose salaries exceed that of the
manager of one or more departments that they work in. Be sure to maintain all the relevant integrity
constraints.

page 2 of 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy