Академический Документы
Профессиональный Документы
Культура Документы
Code : SWE1004
Course Title : Database Management Systems Lab
Class Nbr(s) :
Mark split UP
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
ii) Find out the orders whose order amount is more than 12000 and also find the new
order amount as original order amount * 5.
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
ii) Display employees where the first name or last name starts with S.
v) Display how many employees joined in each month of the current year.
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