0% found this document useful (0 votes)
4 views5 pages

DBMS Lab Assignment2

The document outlines a DBMS lab assignment that includes creating and populating tables for customers, salesmen, orders, and books, along with various SQL queries to retrieve and manipulate data. It specifies the schema for each table, the allowed data types, and provides example entries. Additionally, it includes a series of SQL query tasks related to employee and department information.

Uploaded by

shubham17mittal
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)
4 views5 pages

DBMS Lab Assignment2

The document outlines a DBMS lab assignment that includes creating and populating tables for customers, salesmen, orders, and books, along with various SQL queries to retrieve and manipulate data. It specifies the schema for each table, the allowed data types, and provides example entries. Additionally, it includes a series of SQL query tasks related to employee and department information.

Uploaded by

shubham17mittal
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

DBMS LAB ASSIGNMENT

1. Create the table Customer, Salesman, and order as per the schema given below and
insert any ten suitable entries in created table.
Customer (Cust_ID, cust_name,City,Grade,Salesman_ID) ,
Salesman (SalesMan_ID,Name, Commission,City)
Allowed Data Types of Customer table are:
Cust_ID INTEGER
Cust_name varchar
City varchar
Grade INTEGER
Salesman_ID INTEGER

S.No Cust_ID cust_name City Grade Salesman_ID


1 3002 Nick Rimando New York 100 5001
2 3007 Brad Davis New York 200 5001
3 3005 Graham Zusi California 200 5002
4 3008 Julian Green London 300 5002
5 3004 Nickolas USA 400 5003

Allowed Data Types of Salesman table are:


Salesman_ID INTEGER
Name varchar
City varchar
Commission Decimal

S.No Salesman_ID Name City Commission


1 5001 James Hoog New York 0.15
2 5002 Nail Knite Paris 0.13
3 5005 Pit Alex London 0.11
4 5006 Mc Lyon Paris 0.14
5 5007 Paul Adam Rome 0.13
create a table Order as per the schema given below:
Order (Order_no, Order_date,Purchase_amt,Cust_ID, Salesman_ID)
Allowed Data Types of Order table are:
Order_no INTEGER
Order_date DATE
Purchase_amt Double
Cust_ID INTEGER
Salesman_ID INTEGER

S.No Order_no Order_date Purchase_amt Cust_ID Salesman_ID


1 70001 2012-10-05 150.5 3005 5002
2 70009 2012-09-10 270.65 3001 5005
3 70002 2012-10-06 65.26 3002 5001
4 70004 2012-08-17 110.5 3009 5003
5 70007 2012-09-10 948.5 3011 5002

Q.1.1 Write a query to find those customers with their name and those salesmen with their
name and city who lives in the same city.

Expected Output:
Nick Rimando James Hoog New York
Brad Davis James Hoog New York

Q.1.2 Write a SQL statement to find the names of all customers along with the salesmen who
works for them.
Expected Output:
Nick Rimando James Hoog
Brad Davis James Hoog
Graham Zusi Nail Knite
Julian Green Nail Knite
Q.1.3 Write a query that produces all customers with their name, city, salesman and
commission, who served by a salesman and the salesman works at a rate of the commission
within 12% to 14%.
Expected Output:
Customer City Salesman commission
Graham Zusi California Nail Knite 0.13
Julian Green London Nail Knite 0.13

Q.1.4 Find all customers with orders on October 5, 2012.

Expected Output:
3005 Graham Zusi California 200 5002 70001 150.5 2012-10-05 3005 5002

Q.1.5 Write a SQL statement that produces all orders with the order number, customer name,
commission rate and earned commission amount for those customers who carry their grade is
200 or more and served by an existing salesman.
Expected Output:
ord_no cust_name Commission% Commission
70005 Graham Jusi 0.13 19.565

2. Create the table as per given schema and insert any ten suitable entries in created table.
Book (Book_No, Title , Author, Price)
Allowed Data Types of Columns in State table are:
Book_No INTEGER
Title varchar
Author varchar
Price BigInt

S.No Book_No Title Author Price


1 22 Introduction to Coreman 2500
Algorithms
2 33 Compiler Alfred V Aho 1200
Design
3 12 Network and Forozan 1300
Coomunication
4 10 DataBase Navathe 1000
Management
System
5 900 Formal Theory JC Martin 900
of
Machines and
Automata

Write the following queries over the database created in question 2:


Q.2.1. Display the Book whose Title starts with ‘C’.
Expected Output:
1 22 Introduction to Algorithms Coreman 2500
Q.2.2 Delete the record whose Author name starts with ‘J’
Expected Output: Record whose author is JC Martin is deleted
Q.2.3 Display the record where author name contains the letter with ’ro’.
Expected Output:
3 12 Network and Communication Forozan 1300

3. Consider the following schemas of the tables:


Employee (employee_id, first_name, last_name, email, phone_number, hire_date,
job_id, salary, commission_pct, manager_id, department_id)
Department (department_id , department_name , manager_id ,location_id)
Jobs (job_id , job_title, min_salary , max_salary)
Write SQL queries for the following questions

Q.3.1. Write a query to find the name (first_name, last_name), department_id and name of all the
employees.

Q.3.2. Write a query to display department name, name (first_name, last_name), hire date, salary of
the manager for all managers whose experience is more than 15 years.
Q.3.3 Write a query to display job title, employee name, and the difference between salary of the
employee and minimum salary for the job.
Q.3.4 Write a query to display the job title and average salary of employees.
Q3.5 Write a query to get the maximum and minimum salary from employees table.
Q.3.6. Write a SQL statement to increase the salary of employees under the department 40, 90 and
110 according to the company rules that, salary will be increased by 25% for the department 40, 15%
for department 90 and 10% for the department 110 and the rest of the departments will remain same.
Q.3.7. Write a SQL statement to get all information about the employees but limiting to only 7.
Q.3.8. Write a SQL statement to change salary of employee to 8000 whose ID is 105, if the existing
salary is less than 5000.
Q.3.9 Write a query to display the first_name of all employees who have both "b" and "c" in their first
name.
Q.3.10. Write a query to get monthly salary (round 2 decimal places) of all employees.
Q.3.11. Write a query to get the number of employees working with the company.
Q.3.12. Write a query to get the average salary and number of employees in the employees table.
Q.3.13. Write a query to get the total salaries payable to employees.
Q.3.14. Write a query to get the names (first_name, last_name), salary, PF of all the employees (PF is
calculated as 15% of salary).

You might also like