0% found this document useful (1 vote)
582 views

Menu - 634641184925996250 - CS4106 Database Management Systems Lab Assignment

This document contains lab assignments and exercises on database management systems involving creating tables, inserting data, and writing SQL queries to retrieve and manipulate data. The assignments cover concepts like primary keys, foreign keys, joins, aggregation, sorting, filtering, updating, and deleting records in tables. Sample schemas include tables like EMP, DEPT, CUSTOMER, BRANCH, PROJECT, and CLIENT_MASTER. Queries are provided to select, update, delete records based on conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
582 views

Menu - 634641184925996250 - CS4106 Database Management Systems Lab Assignment

This document contains lab assignments and exercises on database management systems involving creating tables, inserting data, and writing SQL queries to retrieve and manipulate data. The assignments cover concepts like primary keys, foreign keys, joins, aggregation, sorting, filtering, updating, and deleting records in tables. Sample schemas include tables like EMP, DEPT, CUSTOMER, BRANCH, PROJECT, and CLIENT_MASTER. Queries are provided to select, update, delete records based on conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

SEMESTER-IV

CS 4106

DATABASE MANAGEMENT SYSTEM

LAB ASSIGNMENT

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING, B. I. T. MESRA

(1)

EMP (EC, EN, DNO, DESIGNATION, BASIC)


DEPT (DNO, DNAME, DLOC)
WHERE EC CHAR (5) PRIMARY KEY | EMP TABLE
DNO NUMBER (2) FORGIEN KEY
AND DNO NUMBER (2) PRIMARY KEY | DEPT TABLE

(2)

(i)

FIND THE NAME OF EMPLOYEES WORKING IN EITHER COMPUTER DEPT OR CIVIL


DEPT.

(ii)

FIND THE NAME & DEPT NAME WHO DRAWS THE SECOND MAXIMUM SALARY.

(iii)

UPDATE THE EMPLOYEES RECORD BY INCEASING 10% OF SALARY WHO IS


EITHER WORKING IN COMPUTER OR CIVIL DEPT.

(iv)

DELETE THE MECHANICAL DEPT FROM DEPT TABLE.

(v)

DISPLAY THE MAXIMUM SALARY DRAWN FROM EACH DEPT.

CUSTOMER (S# <P.K>, CN, STREET, CITY)


BRANCH (BR_NAME<P.K>, ASSET, BR_CITY)
DEPOSIT (S#<F.K>, CN, BR_NAME, ANO, BALANCE)
BORROW (S#<F.K>, CN,BR_NAME, LNO, AMOUNT)

(3)

(i)

FIND THE CUSTOMER NAME WHO HAS BOTH DEPOSIT & TAKEN LOAN FROM
"UCO" BRANCH.

(ii)

FIND CN, STREET & CITY WHO HAS DEPOSIT BUT NOT TAKEN LOAN FROM "UCO"

(iii)

THE BRANCHES LOCATED IN "RANCHI"CITY.

(iv)

REMOVE ALL THE RECORDS FROM BRANCH TABLE LOCATED IN BRANCH WHERE
CITY IS "JAMSHEDPUR".

(v)

FIND THE NAME OF THE CUSTOMER WHO HAS DEPOSIT IN HIGHEST ASSET
BRANCH.

EMP (EC, EN, ADDRESS)

PROJECT (PNO, PNAME)


WORK_IN(EC, PNO, HOURS)
WHERE EC ANDPNO ARE PRIMARY KEY IN THE TABLE EMP AND PROJECT RESPECTIVELY AND EC
AND PNO IS FORIGEN KEY IN WORK_IN TABLE
(i) FIND THE NAME OF THE EMPLOYEES WHO IS WORKING IN PROJECT B.E
(ii) FIND THE NAME OF THE EMPLOYEES WHO ARE NOT WORKING IN ANY PROJECT.

4.

CREATE THE TABLE DESCRIBE BELOW:--

TABLE CLIENT_MASTER
-----------------------------------------------------------------------COLUMN NAME

DATA TYPE

SIZE

-----------------------------------------------------------------------CLIENT_NO

VARCHAR2

NAME

VARCHAR2

20

ADDRESS1

VARCHAR2

30

ADDRESS2

VARCHAR2

30

CITY

VARCHAR2

15

PINCODE

NUMBER

STATE

VARCHAR2

15

BAL_DATE

NUMBER

10,2

INSERT THE FOLLOWING DATA INTO THEIR RESPECTIVE TABLE:-DATA FOR CLIENT_MASTER TABLE
-------------------------------------------------------------------------------------------------------------CLIENT_NO

NAME

CITY

PINCODE

STATE

--------------------------------------------------------------------------------------------------------------C0001

ABHISHE

MUMBAI

400054

MAHARASTRA

C0002

RADHA

CHENNAI

780001

TAMILNADU

C0003

DEEPAK

MUMBAI

400057

MAHARSTRA

C0004

RITIKA

MUMBAI

400056

MAHARSTRA

C0005

RAVI

DELHI

100001

DELHI

C0006

BIMAN

KOLKATA

700024

W.B

EXERCISE ON RETRIVING RECORDS FROM A TABLE


(i)

FIND OUT THE NAME OF ALL THE CLIENTS

(ii)

RETRIEVE THE ENTIRE CONTENTS OF THE CLIENT_MASTER

(iii)

RETRIEVE THE LIST OF NAMES & THE CITIES OF ALL THE CLIENTS

(iv)

LIST ALL THE CLIENTS WHO ARE LOCATED IN "MUMBAI"

(v)

UPDATE (CHANGE)THE CITY OF CLIENT_NO '0005' TO "RANCHI"

(vi)

DELETE FROM CLIENT_MASTER WHERE THE COLUMN STATE HOLD THE


VALUES"TAMILNADU"

(vii)

CHANGE THE NAME OF CLIENT_MASTER TABLE TO EMP_MASTER

(viii)

ADD COLUMN CALLED "TELEPHONE"OF DATA TYPE NUMBER AND SIZE='10' TO


CLIENT_MASTER TABLE

CUSTOMER (CN, STREET, CITY)


5. FIND OUT THE EMPLOYEES WHO IS BELONGING FROM METROPOLITIAN CITIES.

6. Create Table name client_master data_types are client no.(p.k.), name (not null), address, city, pincode, state,
bal_date
1. Find name of all client having 'a' as tyhe second leter in their names
2.

Find out the clients who stay in a city whose second letter is 'a'

3. Find the list of all client who stay "ranchi" or "kolkata"


4. Find the list of clietno whose bal_due is greater than value
100000.

7.Comsider the following relational schema


employee(empno, name, office, age)
books(isbn, title, authors, publisher)
loan(empno, isbn, date)write the following queries in SQL
(i)print the names of employees who have borrowed any book published by McGraw-Hill.
(ii)print the names of employees who have borrowed all books published by McGraw-Hill
(iii) For each publisher,print the names of employees who have borrowed more than five books of that publisher.

8.Write down the following in Sql queries


Employee(employee_name,street,city)
Works(employee_name,company_name,salary)
Company(company_name,city)
Manages(Empyoyee_name,manager_name)

(i)find the names and cities of residence of all employees who work for first bank corporation
(ii)Find the names,street address and cities of residence of all employees who work for first bank corporation and
earn more than $10000
(iii)Find all employees in the database who do not work for first bank corporation
(iv)Find all employees in database who earn more than each employees of small bank corporation
(v)Assume that the companies may be located in several cities .Find all companies located in every city in which
small bank corporation is located.
(vi)Find the company that has the most employees
(vii)Find those companies whose employees earn a higher salary,on average,than the average salary at first bank
corporation.

9.Create an employee
database(EN,EC,DNO,DN,SALARY,COMMI_ON_SALARY,JOB_TYPE,DATE_OF_JOIN) perform the
following quries:--a.select all information from emp
b.List all emp having salary between 2000 to 10000
c.List dno and DN in Dno order.
d.Display different job types
e.List names and salaries all clerks in dept 20
f.Display all emp with Dr in their names.
g.Display all employees hired during 2005
h.Display names,salary and commission of all employees whose monthly salary is greater than their commission.

10.Create table of the following:--Emp(empid,ename,age,salary)

Works(empid,did,totaltime,projectname,hours)
Dept(Dname,did,budget,Mgrid)solve the following quries:---

a.List the names and ages of each employees who works in both H/W and S/W dept
b.Find the Mgrid of managers who manage only dept with budget greater than 100000
c.Find ename of mgrs who manage the dept with largest budget
d.For each dept with more than 20 emps,print the did together with the no of employees that work in that dept
e.Find the names of all emps ,who work in same dept as theX
f.List the name of emps who have no dept
g.List the names of emps who have 2 or more dept
h.Insert integrity constraint(domain key,foreign key,& check constraint)or assertion to ensure the following
requirement:--i.employees must make a min salary of Rs 2000/-.define a table constraint on Emp
j.Every manager must be an employee
k.A manager must have a higher salary than any employee he/she manages
l.Define a table constraint on dept to ensure that all manager have age>30.

11.Using the following inbuilt functions while retrieving information from any table.
(a)length(b)substr(c)replace(d)ltrim(e)rtrim(f)lpad(g)stddev(h)vsize(i)initcap(j)variance

12.write SQL statements for the following:-a.Convert a char to its ASCII value
b.Translate a numeric value into a string value
c.Convert default dates to strings
d.Make a outer join of two tables

You might also like