0% found this document useful (0 votes)
22 views17 pages

DBMSlab EDITED

The document describes a database assignment involving creating tables and inserting values. It includes tables for programmers, software, and studies. It then lists 39 queries to run on the tables.

Uploaded by

yokef13199
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)
22 views17 pages

DBMSlab EDITED

The document describes a database assignment involving creating tables and inserting values. It includes tables for programmers, software, and studies. It then lists 39 queries to run on the tables.

Uploaded by

yokef13199
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

Assignment-1

Create the following tables:-

Programmer (Name, DOB, DOJ, Sex, Prof1, Prof2, Salary)

Studies (Name, SPLACE, Course, CCost)

Software (Name, Title, Dev_in, SCost, DCost, Sold)

Insert the following values into tables:-

Programmer Table
PNAME DOB DOJ SEX PROF1 PROF2 SALARY
ANAND 12-APR-66 21-APR-92 M PASCAL BASIC 3200
ALTAF 02-JUL-64 13-NOV-90 M CLIPPER COBOL 2800
JULIANA 31-JAN-60 21-APR-90 F COBOL DBASE 3000
KAMLA 30-OCT-68 02-JAN-92 F C DBASE 2900
MARY 24-JUN-70 01-FEB-91 F CPP ORACLE 4500
NELSON 11-SEP-85 11-MAR-89 M COBOL DBASE 2500
PATTRICK 10-NOV-65 21-APR-90 M PASCAL COBOL 2800
QADIR 31-AUG-65 21-APR-90 M ASSEMBLY C 3000
RAMESH 03-MAY-67 26-FEB-91 M PASCAL DBASE 3200
REBECCA 01-JAN-67 01-DEC-90 F BASIC COBOL 2500
REMITHA 19-APR-70 20-APR-93 F C ASSEMBLY 3000
REVATHI 02-DEC-69 02-JAN-92 F PASCAL BASIC 3200
VIJAYA 14-DEC-65 02-MAY-92 F FOXPRO C 4500

Software Table
PNAME TITLE DEV_IN SCOST DCOST SOLD
MARY README CPP 100.00 1200 84
ANAND PARACHUTES BASIC 400 6000 43
ANAND VIDEOTITLING PASCAL 7500 16000 9
JULIANA INVENTORY COBOL 3000 3500 0
KAMLA PAYROLLPRG DBASE 9000 20000 7
MARY FINANCIALACC ORACLE 18000 85000 4
MARY CODEGENRRATOP C 4500 20000 23
PATTRICK README CPP 300 1200 84
QADIR BOMBSAWAY ASSEMBLY 750 5000 11
QADIR VACCINES C 1900 3400 21
RAMESH HOTLIMGMT DBASE 12000 35000 4
RAMESH DEADLEE PASCAL 600 4500 73
REMITHA PCUTILITIES C 725 5000 51
REMITHA TSRHELPPKG ASSEMBLY 2500 6000 7
REVATHI HOSPITALMGMT PASCAL 1100.00 75000 2
VIJAYA TSREDITOR C 900.00 700 6

Studies Table
PNAME SPLACE COURSE CCOST
ANAND SABHARI PGDCA 4500
ALTAF COIT DCA 7200
JULIANA BITS MCA 22000
KAMLA PRAGATHI DCP 5000
MARY SABHARI PGDCA 4500
NELSON PRAGATHI DAP 6200
PATRICK PRAGATHI DCAP 5200
QADIR APPLE HDCP 14000
RAMESH SABHARI PGDCA 4500
RESECCA BRILLIANT DCAP 11000
REMITHA BDPS DCS 6000
VIJAYA BDPS DCA 48000

QUERIES
1) Find out the SELLING COST AVERAGE for the packages developed in PASCAL?

2) Display the names and ages of all programmers.


3) Display the course cost of PGDCA course.

4) What is the highest numbers of copies sold by a package?

5) Display the names and date of birth of all the programmer born in JANUARY.

6) Display lowest course fee.

7) How many programmer has done PGDCA course.

8) How much revenue has been earned through sales of packages in C.

9) Display the details of software developed by Ramesh?


10) How many programmers studied at SABHARI?

11) Display the details of PACKAGES whose sales crossed the 20000 mark

12) Find out the number of copies which should be sold in order to recover the development
cost of each package.

13) What is the price of the costliest software developed in BASIC?

14) Display the details of packages for which development cost has been recovered.

15) How many packages were developed in dbase?

16) How many programmers studies at Pragathi?


17) How many programmers paid 5000 to 10000 for their course?

18) What is the average course fee?

19) Display the details of programmers knowing C?

20) How many programmers know either COBOL or Pascal?

21) How many programmers don't know Pascal & C?

22) How old is the oldest male programmers?

23) What is the average age of female programmers?


24) Calculate the experience in years for each programmers and display along with the names
in descending order?

25) Who are the programmers who celebrate their birthday during the current month?

26) How many female programmers are there?

27) What are the languages known by the male programmers?

28) What is the Average salary?

29) How many people draw 2000 to 4000?

30) Display the details of those who don't know Clipper, COBOL or Pascal?
31) How many Female programmers knowing C are above 24 years of age?

32) Who are the programmers who will be celebrating their Birthday within a week?

33 Display the details of those with less than a year's experience?

34 Display the details of those who will be completing 2 years of service this year?

35 Calculate the amount to be recovered for those packages whose development cost has not
been recovered?

36) List the packages which have not been sold so far?

37) Find out the cost of the software developed by Mary?


38) Display the institute’s names from the studies table without duplicates?

39) How many different courses are mentioned in the studies table?

40) Display the names of the programmers whose names contain 2 occurrences of the letter
A?

41) Display the names of programmers whose names contain upto 5 characters.

42) How many female programmers knowing COBOL have more than 2 years experience?

43) What is the length of the shortest name in the programmer table?

44) What is the average development cost of a package developed in COBOL?


45) Display the name, sex, dob(DD/MM/YY format), doj(DD/MM/YYYY format), for all the
programmers .

46) Who are the programmers who were born on the last day of the month?

47) What is the amount paid in salaries of the male programmers who do not know Cobol?

48) Display the title, scost, dcost and difference between scost and dcost in descending order
of difference?

49) Display the name, dob, doj of those month of birth and month of joining are same?

50) Display the names of the packages whose names contain more than 1 word?
Experiment-2
Consider the following relation schemas of a database:-

Sailors(sid: integer, sname: string, rating: integer, age: real)


Boats(bid: integer, bname: string, color: string) Reserves(sid:
integer, bid: integer, day: date)

Consider the following table as instance:-

Sailors Reserves

Boats

Write the following queries in SQL.

1. Find the names of sailors who have reserved boat number 103.

2. Find all sailors with a rating above 7.

3. Find the sids of sailors who have reserved a red boat.

4. Find the names of sailors who have reserved a red boat.


5. Find the colors of boats reserved by Lubber.

6. Find the names of sailors who have reserved at least one boat.

7. Compute increments for the ratings of persons who have sailed two different
boats on the same day.

8. Find the ages of sailors whose name begins and ends with B and has at least
three characters.

9. Find the names of sailors who have reserved a red or a green boat.

10. Find the names of sailors who have reserved both a red and a green boat.

11. Find the sids of all sailors who have reserved red boats but not green boats.

12. Find the names of sailors who have not reserved a red boat.
13. Find sailors whose rating is better than some sailor called Horatio.

14. Find the sailors with the highest rating.

15. Find the names of sailors who have reserved all boats.

16. Find the average age of all sailors.

17. Find the average age of sailors with a rating of 10.

18. Find the name and age of the oldest sailor.

19. Count the number of different sailor names.

20. Find the names of sailors who are older than the oldest sailor with a rating of
10.

21. Find the age of the youngest sailor for each rating level.
22. Find the age of the youngest sailor who is eligible to vote (i.e., is at least 18 years
old) for each rating level with at least two such sailors.

23. For each red boat, find the number of reservations for this boat.

24. Find the average age of sailors for each rating level that has at least two sailors.

25. Find the average age of sailors who are of voting age (i.e., at least 18 years old)
for each rating level that has at least two sailors.

26. Find the average age of sailors who are of voting age (i.e., at least 18 years old)
for each rating level that has at least two such sailors.

27. Find those ratings for which the average age of sailors is the minimum overall
ratings.
Experiment-3
Consider the following employee database:-

Employee (employee-name, street, city)


Works (employee-name, company-name, salary)
Company (company-name, city)
Manages (employee-name, manager-name)

Where the primary keys are underlined. Give an expression in SQL for each of
the following queries.

The tables for the above schemas are the following:-

Employee Table
Employee-name Street City
Neha Naini Prayagraj
Rakesh Indira Nagar Lucknow
Ritika Kakadev Kanpur
Ashok Chandani Chowk Delhi
Manish Civil Line Prayagraj
Shyam Gomti Nagar Lucknow
Abhijeet Harsh Nagar Kanpur

Work Table
Employee-name Company-name Salary
Neha First Bank Corporation 40000
Rakesh Small Bank Corporation 30000
Ritika HDFC Bank 35000
Ashok Small Bank Corporation 25000
Manish First Bank Corporation 15000
Shyam First Bank Corporation 10000
Abhijeet HDFC Bank 20000

Company Table
Company-name City
First Bank Corporation Prayagraj
Small Bank Corporation Delhi
HDFC Bank Kanpur
Yes Bank Corporation Prayagraj
Reliance Lucknow

Manages Table
Employee-name Manager-name
Neha Manish
Rakesh Ashok
Ritika Null
Ashok Null
Manish Null
Shyam Manish

Queries:

(1) Find the names of all employees who work for First Bank Corporation.

(2) Find the names and cities of residence of all employees who work for
First Bank Corporation.
(3) Find the names, street addresses, and cities of residence of all employees
who work for First Bank Corporation and earn more than $10,000.

(4) Find all employees in the database who live in the same cities as the
companies for which they work.

(5) Find all employees in the database who live in the same cities and on the
same streets as do their managers.

(6) Find all employees in the database who do not work for First Bank
Corporation.

(7) Find all employees in the database who earn more than each employee
of Small Bank Corporation.

(8) Assume that the companies may be located in several cities. Find all
companies located in every city in which Small Bank Corporation is
located.
(9) Find all employees who earn more than the average salary of all
employees of their company.

(10) Find the company that has the most employees.

(11) Find the company that has the smallest payroll.

(12) Find those companies whose employees earn a higher salary, on average,
than the average salary at First Bank Corporation.

You might also like