0% found this document useful (0 votes)
15 views

DBMS index1

The document outlines a comprehensive set of SQL programming tasks, including the creation of various tables (e.g., EMPLOYEE, CLIENT, BOOK, SALES) with specified constraints and the execution of multiple SQL queries for data manipulation and retrieval. It also includes PL/SQL programs for operations like debit transactions, stock validation, and employee pay calculations. Additionally, it covers the creation of related tables with primary and foreign keys, ensuring data integrity and appropriate constraints.

Uploaded by

farisfari313e
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)
15 views

DBMS index1

The document outlines a comprehensive set of SQL programming tasks, including the creation of various tables (e.g., EMPLOYEE, CLIENT, BOOK, SALES) with specified constraints and the execution of multiple SQL queries for data manipulation and retrieval. It also includes PL/SQL programs for operations like debit transactions, stock validation, and employee pay calculations. Additionally, it covers the creation of related tables with primary and foreign keys, ensuring data integrity and appropriate constraints.

Uploaded by

farisfari313e
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/ 5

Index

PART-A
Program Page
No. Program title No.
01 Create a table EMPLOYEE using SQL command to store details of
employees such as EMPNO, NAME, DESIGNATION, DEPARTMENT,
GENDER and SALARY. Specify Primary Key and NOT NULL constraints
on the table. Allow only ‘M’ or ‘F’ for the column GENDER.
DEPARTMENT can be SALES, ACCOUNTS, IT. Choose DESIGNATION
as CLERK, ANALYST, MANAGER, ACCOUNTANT and SUPERVISOR
that depends on department .
Write the following SQL queries:
a) Display EMPNO, NAME and DESIGNATION of all employees whose
name ends with RAJ.
b) Display the details of all female employees who is earning salary within
the range 20000 to 40000 in SALES or IT departments.
c) List the different DEPARTMENTs with the DESIGNATIONs in that
department.
d) Display the department name, total, average, maximum, minimum salary
of the DEPARTMENT only if the total salary given in that department is
more than 30000.
e) List the departments which have more than 2 employees.
02 Create a table CLIENT to store CLIENT_NO, NAME, ADDRESS, STATE,
BAL_DUE. Client no must start with ‘C’. Apply the suitable structure for the
columns. Specify Primary Key and NOT NULL constraints on the table. Insert
10 records.
Write the following SQL queries:
a) From the table CLIENT, create a new table CLIENT1 that contains only
CLIENT_NO and NAME , BAL_DUE from specified STATE. Accept the state
during run time.
b) create a new table CLIENT2 that has the same structure as CLIENT but with
no records. Display the structure and records.
c) Add a new column by name PENALTY number (10, 2) to the CLIENT.
d) Assign Penalty as 10% of BAL_DUE for the clients C1002, C1005, C1009
and for others 8%. Display Records.
e) Change the name of CLIENT1 as NEW_CLIENT.
f) Delete the table CLIENT2.
03 Create a table BOOK using SQL command to store Accession No, TITLE,
AUTHOR, PUBLISHER, YEAR, PRICE. Apply the suitable structure for the
columns. Specify Primary Key and NOT NULL constraints on the table. Insert 10
records.
Write the following SQL queries:
a) List the details of publishers having ‘a’ as the second character in their names.
b) Display Accession No., TITLE, PUBLISHER and YEAR of the books
published by the specified author before 2010 in the descending order of YEAR.
Accept author during run time.
c) Modify the size of TITLE to increase the size 5 characters more.
d) Display the details of all books other than Microsoft press publishers.
e) Remove the records of the books published before 1990.

04 Create a table SALES with columns SNO, SNAME, MANAGER_NAME,


JOIN_DATE, DATE_BIRTH, SALARY,SALES_AMOUNT and
COMMISSION. Minimum age for joining the company must be 18 Yrs. Default
value for Commission should be 0. Apply the suitable structure for the columns.
Specify Primary Key and NOT NULL constraints on the table. Insert 10 records
with data except commission. Manager of Manager can be NULL.
Write the following SQL queries:
a) Display the details of Sales Persons whose salary is more than Average salary
in the company.
b) Update commission as 20% of Sales Amount.
c) Display SNO, SNAME, MANAGER_NAME, SALARY, COMMISSION,
MANAGER_SALARY of the sales persons getting sum of salary and
commission more than salary of manager.(Self join)
d) Display the records of employees who finished the service of 10years.
05 Create a table Sales_Details with the columns SNO, MONTH, TARGET and
QTY_SOLD to store the Sales Details of one year. Specify the composite primary
key to the columns SNO and MONTH. TARGET and SALES must be positive
numbers.
Write the following SQL queries:
a. Display the total sales by each sales person considering only those months sales
where target was reached.
b. If a commission of RS.50 provided for each item after reaching target, calculate
and display the total commission for each sales person.
c. Display the SNO of those who never reached the target.
d. Display the SNO, MONTH and QTY_SOLD of the sales persons with SNO
S0001 or S0003
06 Create a table Bank with the columns ACNO, ACT_NAME, ACT_TYPE and
BAL. Specify the Primary Key. Initial BAL must be greater than 500. Write a
PL/SQL program to perform debit operation by providing acct_no and amount
required. The amount must be greater than 100 and less than 20000 for one
transaction. If the account exist and BAL-amount>100 Bank table must be
updated, otherwise “NO SUFFFICIENT BALANCE” message should be
displayed. If account number is not present then display “NO SUCH
ACCOUNT” message to the user.
07 Create a table STOCK_DETAIL with the columns PNO, PNAME and QTY_AVL
to store stock details of computer accessories. Specify Primary Key and NOT
NULL constraints on the table. QTY_AVL should be positive number. Write a
PL/SQL Program to define a user defined exception named “LOW_STOCK” to
validate the transaction. The program facilitates the user to purchase the product by
providing product number and quantity required. It should display an error
message “NO SUFFICIENT STOCK” when the user tries to purchase a product
with quantity more than QTY_AVL, Otherwise the STOCK_DETAIL table should
be updated for valid transaction.
PART-B

Program Program title Page


No. No.
01 Create the following tables by identifying primary and foreign keys. Specify the not
null property for mandatory keys. SUPPLIERS (SUPPLIER_NO, SNAME,
SADDRESS, SCITY)
COMPUTER_ITEMS(ITEM_NO,SUPPLIER_NO,ITEM_NAME, IQUANTITY)
Consider three suppliers. A supplier can supply more than one type of items.
Write the SQL queries for the following
a. List ITEM and SUPPLIER details in alphabetical order of city name and in each
city decreasing order of IQUANTITY.
b. List the name ,city,and address of the suppliers who are supplying keyboard.
c. List the supplier name, items supplied by the suppliers ‘Cats’ and ‘Electrotech’.
d. Find the items having quantity less than 5 and insert the details of supplier and item
of these, into another table NEWORDER.
02 Create the following tables identifying Primary and Foreign keys. Specify the not null
property for mandatory keys. EMPLOYEE_MASTER (EMP_ID, EMP_NAME,
EMAIL_ID, EMP_ADDRS, PHONE) ATTENDANCE (EMP_ID, MONTH, WOM,
MHRS, THRS, WHRS, TRHRS, FHRS, SHRS, SUHRS). (Valid values for WOM<=5,
MONTH can be 1-12). Apply appropriate constraints. Consider 3 employees. And
attendance records for at least two months. Write the SQL queries for the following
a) Display EMP_ID,EMP_NAME and EMAIL_ID of all employees who are working
on every Sunday of 2nd and 4th week in a month.
b) Display total hours worked by each employee in each month with EMP_ID.
c) Display the names of the employees who never attended the duty so far(Attendances
not given so far).
d) Display the employee name, month, week, total hours worked for employees who
have total no. of hours more than 20 hrs. a week.
03 Create the following tables by identifying primary and foreign keys, specify the not null
property for mandatory keys.
PRODUCT_DETAIL
P_NO PRODUCTNAME QTYAVAILABLE PRICE PROFIT %
P0001 Monitor 10 3000 20
P0002 Pen Drives 50 650 5
P0003 CD Drive 100 10 3
P0004 Key Board 25 600 10
PURCHASED_DETAIL
CUSTNO P_NO QTYSOLD
C1 P0003 2
C2 P0002 4
C3 P0002 10
C4 P0001 3
C5 P0004 2
C6 P0003 2
C7 P0004 1
Write the following SQL queries:
a) Display total amount spent by C2.
b) Display the names of product for which either QtyAvailable is less than 30 or total
QtySold is less than 5(USE UNION).
c) Display the name of products and quantity purchased by C4.
d) How much Profit does the shopkeeper gets on C1’s purchase?
e) How many ‘Pen Drives’ have been sold?
04 Create table STUDENT_PROFILE includes Rollno, name, class, ECCC(Extra-Co
curricular he belongs to such as SPORTs, NSS etc.) and another table
MARKS_REPORT includes Rollno, Internal_Test, Marks1, Marks2, Marks3 and
ECCC_marks.
Constraints
• Internal _Test can be either 1 or 2.
• Each mark can be 0-100. Absence in the test can be entered as -1.
• Consider atleast 3 classes.
Apply suitable data type and constraints to each column.
Insert 5 students marks report in the both the tests.
Write the following SQL queries:
a) Find number of students failed class- wise.
b) Display the complete details of the students secured distinction(Percentage>=70) in I
BCA.
c) Display class and highest total marks in second internals in each class.
d) Display the student name with rollno and class of those who passed in I internals and
failed in II internals.(use SET operator)
05 Write a PL/SQL program to compute the selling price of books depending on the book
code and category. Use Open, Fetch and Close. The Book_detail table contains
columns: Book Code, Author, Title, Category and Price. Insert 10 records. The selling
price=Price-Discount.
The discount is calculated as follows:
Book Code Category Discount Percentage

A Novels 10% of Price


Technology 12.5% of Price
B Commerce 18% of Price
Science 19% of Price
C Songs 25% of Price
Sports 24% of Price
D All 28% of Price
Print the result in tabular form with proper alignment
Book Code category title author price discount % discount amount sell
price
===== ======= ===== ==== ===== ====== =====
-----------------------------------------------------------------------------------------
06 Write a PL/SQL program to display employee pay bill (using Cursor For loop) Use a
Procedure to receive basic pay and to compute DA, HRA, Tax, PF, Gross Pay and Net
Pay(Use OUT). Base table contains the following columns empnum, empname, basic
pay. Insert 3 records.
Allowances are computed as follows.
Basic Pay DA HRA
<=20000 35% of Basic 8% of Basic
>20000 & <=30000 38% 9%
>30000 & <=40000 40% 10%
>40000 45% 10%
Gross=Basic+DA+HRA PF=12% of Gross or Rs. 2000 whichever is minimum. PT=Rs.
100 upto Gross is 25,000 else Rs. 200. Net=Gross-(PF+PT) Print Pay slip as follows.

You might also like