0% found this document useful (0 votes)
23 views7 pages

DBMS Ia2

The document covers various aspects of relational databases, including unary relational operations, relational algebra operations like JOIN and UNION, and SQL queries for specific database schemas. It also discusses SQL commands such as INSERT, DELETE, and UPDATE, as well as concepts like triggers, assertions, and stored procedures. Additionally, it explores advanced topics like dynamic SQL, JDBC, and the structure of a 3-tier architecture.

Uploaded by

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

DBMS Ia2

The document covers various aspects of relational databases, including unary relational operations, relational algebra operations like JOIN and UNION, and SQL queries for specific database schemas. It also discusses SQL commands such as INSERT, DELETE, and UPDATE, as well as concepts like triggers, assertions, and stored procedures. Additionally, it explores advanced topics like dynamic SQL, JDBC, and the structure of a 3-tier architecture.

Uploaded by

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

Module:2

1. Explain Unary relational operations with examples.

2. Explain the following relational algebra operation.

JOIN, DIFFERENCE, SELECT, UNION

3. Explain the relational algebra operation for set theory with examples.

4. Consider the Sailors-Boats-Reserves DB described

S (sid, sname, rating, age)

B (bid, bname, color)

R (sid, bid, date)

Write each of the following queries in SQL.

1. Find the colors of boats reserved by Alber.


2. Find all sailor ids of sailors who have a rating of at least 8 or reserved
Boat 103.
3. Find the names of sailors who have not reserved a boat whose name
Contains the string “storm”. Order the names in ascending order.
4. Find the sailor ids of sailors with age over 20 who have not reserved A
boat whose name includes the string “thunder”

5 Discuss the Equijoin & Natural Join with suitable example.

6 Explain with examples, the basic constraints that can be specified when a
database table is created in SQL.

7 Write SQL queries for the following relational schema:

CUSTOMER (CID, CNAME, EMAIL, ADDR, PHONE)

ITEM (ITEM_NO, ITEM_NAME, PRICE, BRAND)

SALES (CID, ITEM_NO, #ITEMS, AMOUNT, SALE_DATE)

SUPPLIER (SID, SNAME, SPHONE, SADDR)

SUPPLY (SID, ITEM_NO, SUPPLY_DATE, QTY)

i) List the items purchased by customer ‘Prasanth’.


ii) Retrieve items supplied by all suppliers starting from 1 st Jan 2019 to
30th Jan 2019.
iii) Get the details of customers whose total purchase of items worth
more than 5000 rupees.

iv) List total sales amount, total items, average sale amount of all items.

iv) Display customers who have not purchased any items

8 Consider the following COMPANY database


EMP(Name,SSN,Salary,SuperSSN,Gender,Dno)

DEPT(DNum,Dname,MgrSSN,Dno)

DEPT_LOC(Dnum,Dlocation)

DEPENDENT(ESSN,Dep_name,Sex)

WORKS_ON(ESSN,Pno,Hours) PROJECT(Pname,Pnumber,Plocation,Dnum)

Write the relational algebra queries for the following

(i)Retrieve the name, address, salary of employees who work for the
Research Department.

(ii) find the names of employees who work on all projects controlled by
department Number4.

(iii) Retrieve the SSN of all employees who either in department no :4 or


directly supervise an employee who work in department number :4

(iv) Retrieve the names of employees who have no dependents

(v) Retrieve each department number, the number of employees in the


department and Their average salary.

9 Consider the following relation schema

Works(Pname,Cname,salary)

Lives(Pname,Street,City)

Located_in (Cname, city)

Manager(Pname,Mgrname)

Write the SQL queries for the following

i) Find the names of all persons who live in the city Bangalore.
ii) Retrieve the names of all person of “Infosys” whose salary is
between Rs .50000
iii)Find the names of all persons who lives and work in the same city

iv)List the names of the people who work for “Tech M” along with the
cities they live in.

v)Find the average salary of “Infosys” persons

10 Write SQL syntax for the following with example:

(i) SELECT
(ii) ALTER
(iii) UPDATE

11 Consider the following tables:

Works (Pname, Cname, Salary)

Lives (Pname, Street, City)

Located_in (Cname, City)

Write the following queries in Relational algebra:

i) List the names of the people who work for the Company ‘Wipro’
along with the cities they live in.
ii) Find the names of the persons who do not work for ‘Infosys’.
iii) Find the people whose salaries are more than that of all the ‘Oracle’
employees.

iv) Find the persons who work and live in the same
City.

iv) Find the names of the companies that are located in every city
where the Company Infosys is located.

12 Write SQL query for the following database scheme:

Employee(employee_name, street, city)

Works(employee_name, company_name, salary)

Company(company_name, city)

Manages(employee_name, manager_name)

i) Find the names, street address, and cities of residence for all
employees who work for ‘First Bank Corporation’ and earn more
than $10,000.
ii) Find the names of all employees in the database who do not
work for ‘First Bank Corporation’. Assume that all people work for
exactly one company.
iii) Find the names of all employees in the database who earn more
than every employee of ‘Small Bank Corporation’. Assume that
all people work for at most one company.

iv) Find the name of the company that has the smallest payroll.

iv) Find the names of all employees in the database who live in the
same cities and on the same streets as do their managers.

13 Given the following schema

Emp (Fname, Lname, SSN, bdate, address, gender, salary, superSSN, dno)

Dept (dname, dnumber, mgrSSN, mgrstartdate)

Dept_loc (dnumber, dloc)

Project (Pname, Pnumber, Ploc, dnum)

Works_on (ESSN, Pno, hours)

Dependent (ESSN, dependent_name, gender, bdate, relationship)

Give the relation algebra expression for the following:

i) Retrieve the name and address of all employees who work for
‘sports’ department.
ii) Retrieve each department number, number of employees and their
average salary.
iii) List the project number, controlling department number and
department manager’s last name, address and birthdate.

iv) Retrieve the name of employees with 2 or more dependents.

iv) List female employees from dno = 20 earning more than 50000.

Module:3

1 Illustrate insert, delete, update, alter & drop commands in SQL.

2 Explain the types of update anomalies in SQL with an example.

3 What are assertions and triggers in SQL? Write a SQL program to create an
assertion to specify the constraint that the salary of an employee must not
be greater than the salary of the department. The employee works for in the
COMPANY database.

4 Explain cursors and its properties in embedded SQL with suitable example.

5 How are triggers defined in SQL? Explain with example.

6 Illustrate aggregate functions in SQL.

7 With an example, explain stored procedures in SQL.

8 Write a trigger in SQL to call a stored procedure INFORM_SUPERVISOR()


whenever a new record is inserted or updated, check whether an employee’s
salary is greater than the salary of his or her direct supervisor in the
COMPANY database.

9 How do you create a view in SQL? Give examples. Can you update a view
table? If yes, how? If not, why not? Discuss.

10 With real world examples, explain the following:

i) JDBC
ii) Correlated queries
iii) Stored Procedure
iv) Schema change statements in SQL.

11 Explain the following constructs used in SQL with example:

i) Nested queries
ii) Aggregate functions
iii) Triggers
iv) Views and their updability
v) Schema change statements

12 What is Dynamic SQL? How it is different from Embedded SQL

13 Draw and explain 3-tier Architecture and technology relevant to each tier.
Write the Advantages of 3- tier architecture.

14 What is SQLJ? How it is different from JDBC.

15 Discuss EXISTS and UNIQUE functions in SQL. Consider the COMPANY


database given in Question number 04, write a query to list the name of the
Manager who have atleast one dependent.

With a real World example, explain the following :

i) JDBC
ii) Correlated nested queries
iii) Stored Procedures
iv) Schema change statements in SQL

16 Explain the usage of Aggregate function in SQL. Write an SQL query to


find sum of the salaries of all employees, the maximum salary, the minimum
salary and the average salary by renaming the columns in a single row table.

17 Create an HTML form to collect user ID and password fields and it also has
to have two buttons: one for reset and another for login.

18 Write a short note on: i) JavaScript ii) CGI

19 Describe the six clauses in the syntax of an SQL retrieval query. Show
what type of constructs can be specified in each of the six clauses. Which of
the six clauses are required and which are optional?

20 How are Triggers and Assertions defined in SQL? Explain.

Consider the following tables:

Branch (Bname, Bcity, Assets)

 Account (Accno, Bname, Accbal)

 Loan (Loan_no, Bname, LoanAmt)

 Customer (Cname, Cstreet, CCity)

 Depositer (Cname, Accnum)

 Borrow (Cname, Loannum)

Write the following queries in SQL:

 Find all loan numbers for loans made at Cantonment branch with loan amounts greater
than 20,000.
 Find the names of all customers whose street address includes 'Main'.
 Find the average balance for each branch, if the average balance is greater than 12,000.
 Find the names of all customers who have an account at all the branches located in
"Mysore".
 Find all customers who do not have a loan at the bank, but do have an account.
21 Illustrate aggregate functions in SQL.
22 Define Database stored procedure. Explain creating and calling stored
procedure with example.

You might also like