Вы находитесь на странице: 1из 7

Programme : M.

Tech Software Engineering Semester : winter ’17 – ’18

Code : SWE1004
Course Title : Database Management Systems Lab
Class Nbr(s) :

Faculty (s) : Dr.Sivabalakrishnan.M && Prof. Slot :


L55+L56
Graceline Jasmine S

Time : 2 hours Max. Marks : 40

Mark split UP

Table creation and insertion 12 Marrks

Sql query 15 marks

Pl SQL 13 marks

Total 40 Marks

1 Create Tables as follows by choosing appropriate data type and set the necessary
) primary and foreign key constraints:
Create the following tables: [If already exists, DROP the existing table]
1) SALESMEN
Table Structure:
Field Type Constraint
SID VARCHAR2 (5) P.K.
SNAME VARCHAR2 (20) Not Null
CITY VARCHAR2 (15) Not Null
SALARY NUMBER (5, 2)
PRODUCT VARCHAR2 (20)
TGTTOGET NUMBER (5,2)
COMM NUMBER (5,2)
2) CUSTOMERS
Table Structure:
Field Type Constraint
CID VARCHAR2 (5) P.K.
CNAME VARCHAR2 (20) Not Null
CITY VARCHAR2 (15) Not Null
STATE VARCHAR2 (15)
PINCODE NUMBER (8)
PRODUCT VARCHAR2 (20)
CLASS CHAR (1) Default value 'A'
3) ORDERS
Table Structure:
Field Type Constraint
OID VARCHAR2 (5) P.K.
CID VARCHAR2 (5) F.K. (CUSTOMERS)
SID VARCHAR2 (5) F.K. (SALESPEOPLE)
PRODUCT VARCHAR2 (20)
QTY NUMBER (5)
ODATE DATE Not Null
O_AMT NUMBER (8, 2) Minimum zero

A). Write the following queries in SQL

i) Find the customer city of customer which order amount is minimum

ii) Find out the orders whose order amount is more than 12000 and also find the new
order amount as original order amount * 5.

iiI) Display customer name whose salesman staying in Ahmedabad.


.
iv) Display order info with salesman name which has given on date before 10
of any month.

v) Create a view which shows the detail of salesman with his salary. (Salesmanname,
salary)

B). Increase the commission based on the following conditions: If Salary is more
than 15000, increase commission by 20% If purchase amount is greater than 30000
years, increase commission by 10% Otherwise 5%

2 Create Tables as follows by choosing appropriate data type and set the necessary
primary and foreign key
constraints:

25
A). Write the following queries in SQL
i).Return all students (name only) with 'male' or fmale '' standing and a 'Computer
Science' major.
ii). Return all courses that have 'Data' in their title. Sort them by course name.

iii).Return the students who are above the average student percentage.

iv). retrieves data from the STUDENT table for students whose last names begin with A,B,
or C.

v)create a view name stuinfo contain rollno, student name ,total marks and percentage

.B). Write a PL/SQL code to retrieve the student name, date of birth, and
place from student-personal database of an student whose number is input by the user..

C) Viva - Quiz

3 Create Tables as follows by choosing appropriate data type and set the necessary
primary and foreign key constraints:

25

A). Write the following queries in SQL

i) Display details of the employees where commission percentage is null and


salary in the range 5000 to 10000 and department is 30.

ii) Display employees where the first name or last name starts with S.

iii) Display first name and experience of the employees..

1. iv) Display the first word in job title.

v) Display how many employees joined in each month of the current year.

B) Update salary of employee based on commission percentage. If commission


is 40-69 increase salary by 10%. If commission more than70 then 15%, otherwise
5%.

4 Create Tables as follows by choosing appropriate data type and set the necessary
primary and foreign key constraints:
Customer (Cid, cname, ccity)
Product (Pid, Pname, Pcost, PProfit)
Sales_Detail (cid, Pid, sales, saledt)
State_name(ccity,state)
1. customer table records
CID cname ccity
C1 Pradip Mysore
C3 AAstik Kolkatta
C2 Tushar pune
C4 Arpan chennai
C5 Anumita indore
2. product table records
Pid Pname Pcost
PProfit
P3 Pen 20.5
20
P2 Floppy 30
12
P1 Pencil 5.25
3. Sales_detail records
cid pid sales saledt
c1 p3 2 14-jul-08
c3 p2 10 15-jul-08
c2 p3 1 14-jul-08
c1 p1 5 14-jul-08
c1 p3 3 20-aug-08
c4 p3 2 14-nov-08
c5 p2 2 18-sep-08

4. State_name table
Ccity state
Mysore Karnataka
Kolkate west Bengal
Pune Maharashtra
Chennai tamil nadu
Indore Madhya pradesh

1.Write a query to display cname who has


purchased PEN.
2. Write a query to display cname,pid and saledt of those customers who cie is in
C1 or C2 or C4 or C5.
3.Write a query to display all cname which includes two ‘A’ in the name
4.write a query to display distinct custid whose product id is P3 (54)
5. Write a query to display product name with total sale detail in descenting
order(64)
B.write a query display PID,pname,pcost and revised-pcost. Revised-pcost
for P1 is cost increased by 10%, for P2 cost is increased by 20% and for P3
no increase in cost.

Вам также может понравиться