Assignment-2
Sub: DBMS
1. Consider the following schema:
Supplier (s_id,sname,s_addr)
Parts (p_id,pname,color)
Catalog (s_id,p_id,cost)
Answer the following queries in relational algebra
a) Find the name of all suppliers who supply yellow parts.
b) Find the name of suppliers who supply both blue and black.
c) Find the name of supplier who supply all parts.
2. Consider the flowing database:
Emp_id Project_id
Emp_name
101 Rahul
103 Sachin
104 Ashish
106 Sumit
107 Anil
110 Kapar
112 omkar
Emp_id
101 c-453
103 c-354
104 c-343
104 c-354
106 c-231
106 c-278
106 c-353
106 c-354
106 c-453
107 c-231
107 c-353
110 c-278
112 c-353
112 c-354
project_id project_name Chief_arch
c-231 oracle 107
c-278 java 110
c-353 Operating system 107
c-354 C 104
c-435 VB 101
Write the relational algebra queries for the following:
a) List emp_id of employees working on project c-353.
b) Get details of employees (both number and name) working on project c-353.
c) Obtain the details of employees working on operating system project.
d) Gather the details of employees working on both c-353 and c-354.
e) Find the employee number of all employees who work on atleast all the projects that
employee 107 works on.
f) Find the employee number of employee who do not work on project c-453.
3. Retrieve the TName, and No_of_period of teachers who teach in “ABC”
school using Relational Algebra.
TEACHER (TID, TName, TAddress, TQualification)
SCHOOL (SID, SName, SAddress, SPhone)
SCHOOL_TEACHER (SID, TID, No_of Period).
4. Consider a banking database with three tables and primary keys
underlined as given below:
Customer(CustomerID, CustomerName, Address, Phone, Email)
Owns(CustomerID, AccountNumber)
Account(AccountNumber, AccountType, Balance)
Write both relational algebra and SQL queries:
a. To display name of all customers who live in “Kathmandu”.
b. To count total number of customers.
c. To find name of those customers who have balance greater than or
equal to 100000.
d. To find average balance of each account type.