Shrutika Slip 1 To 5
Shrutika Slip 1 To 5
Shrutika Slip 1 To 5
JoshiFYBBA(CA)
Roll no:13406
DBMS ASSIGNMENT
SLIP 1
Q 1 Consider the following entities and their relationships. Create a RDB in 3 NF
with appropriate data types and Constraints.
Dept(dno,dname ,loc)
Constraints: - Primary Key, ename should not be NULL, salary must be greater
than 0.
1. Add column phone_No into Emp table with data type int.
Ans:
Table created.
5 salary number(10,2)check(salary>0),
6 date_of_joining date
2 values (101,'manager','pune');
1 row created.
2 values(102,'accountant','pimpri');
1 row created.
1 row created.
2 values (104,'quality','pune');
1 row created.
2 values (105,'account','chinchwad');
1 row created.
2 values(1,'Mr. Advait','manager',54000,'23-mar-2004',101,9325155612);
1 row created.
2 values(2,'Mr. Roy','ceo',50000,'15-june-2019',102,9890325284);
1 row created.
2 values(3,'Mr. Abhay','manager',60000,'10-oct-2013’,’103',9860156466);
1 row created.
2 values(4,'Mr. Raghav','manager',420000,'01-mar-2003',104,9503214716);
1 row created.
1 row created.
Q1. Add column phone_No into Emp table with data type int.
Table altered.
3 rows deleted.
2 group by dno;
DNO COUNT(ENO)
---------- ----------
102 1
101 1
104 1
105 1
103 1
2 where EMP06.eno=DEPT06.eno
ENAME
--------------------
MR. advait
3. Display the name of department whose location is “Pune” and “Mr. Advait” is
working in it.
2 where EMP06.eno=DEPT06.eno
DNAME
--------------------
account
4. Display the names of employees whose salary is greater than 50000 and
department is “Quality”.
2 where EMP06.eno=DEPT06.eno
3 and salary>50000
DNO PHONE_NO
---------- ----------
104
1 row updated.
SLIP 2
Q Consider the following entities and their relationships. Create a RDB in 3 NF
with appropriate data types
and Constraints.
ANS:
Table created.
2 values('CN001','Abhay','Pune');
1 row created.
2 values('CN002','Patil','Pune');
1 row created.
2 values('CN003','Mr.Roy','Pimpri');
1 row created.
2 values('CN004','Raj','Mumbai');
1 row created.
2 values('CN005','joshi' ,'mumbai');
1 row created.
Table created.
1. Add column amount into Sales_order table with data type int.
Table altered.
2 values(1,'23-june-2015','CN001',15000);
1 row created.
2 values(2,'09-MAR-2019','CN002',20000);
1 row created.
2 values(3,'09-AUG-2009','CN004',25000);
1 row created.
2 values(4,'09-AUG-2019','CN002',38000);
1 row created.
2 values (5,'10-sep-2008','CN005',50000);
1 row created.
2 set ordDate='18-mar-2019'
1 row updated.
2 order by ordDate;
2 set addr='pimpri'
3 where clientname='Mr.Roy';
1 row updated.
1. Delete sales order details of client whose name is “Patil” and order date is
“09/08/2019”.
2 where ordDate='09-AUG-2019'
1 row deleted.
2. Delete the details of the clients whose names start with ‘A’ character.
1 row deleted.
1 row deleted.
Slip 3
Q3. Consider the following entities and their relationships. Create a RDB in 3 NF
with appropriate data types and Constraints.
3 hname varchar2(20),
4 city varchar2(10),
6 addr varchar2(25));
Table created.
2 values(101,'balaji','pune',1993,'kharadi road');
1 row created.
2 values(103,'vedant','mumbai',1993,'dharavi');
1 row created.
1 row created.
2 values(105,'birla','chinchwad',1993,'BANER');
1 row created.
1 row created.
SQL> create table doctor06
3 dname varchar2(20),
4 addr varchar2(25),
Table created.
2 values(1,'dr.joshi','pune','skin',104);
1 row created.
2 values(2,'dr.mane','nashik','surgeon',103);
1 row created.
2 values(4,'dr.Raghav','pune','skin',105);
1 row created.
2 values(5,'dr.Abhay','mumbai','internist',104);
1 row created.
2 values(3,'dr.patil','pune','AYURVEDIC',101);
1 row created.
Table altered.
2.Display doctor name, Hospital name and specialty of doctors from “Pune City” .
2 where doctor06.hno=hospital06.hno
3 and city='pune';
1. Display the names of the hospitals which are located at “Pimpri” city
2 where doctor06.hno=hospital06.hno
3 and city='pimpri';
HNAME
--------------------
ruby
ruby
2. Display the names of doctors who are working in “Birla” Hospital and city
name is “Chinchwad”.
2 where doctor06.hno=hospital06.hno
DNAME
--------------------
dr.Raghav
3. Display the specialty of the doctors who are working in “Ruby” hospital.
2 where doctor06.hno=hospital06.hno
3 and hname='ruby';
SPECIALITY
----------
skin
internist
4 Give the count of doctor’s hospital wise which are located at “Pimple Gurav”.
SQL> select hname,count(dno) from doctor06,hospital06
2 where doctor06.hno=hospital06.hno
4 group by hname;
No rows selected.
2 rows updated.
Slip 4
Q3. Consider the following entities and their relationships. Create a RDB in 3 NF
with appropriate data types and Constraints. [15 Marks]
Constraints: - Primary key, RoomNo must be greater than Bed_No, Addr should
not be null.
5 diseases varchar2(10));
Table created.
2 values(11,'Raghav','pimple gurav','ALLERGY');
1 row created.
2 values(12,'Abhay','pune','norovirus');
1 row created.
1 row created.
2 values(14,'Sachin','pimple gurav','dengue');
1 row created.
2 values(15,'Priya','nashik','listeria');
1 row created.
3 ROOMNO NUMBER(5),
4 LOC VARCHAR2(10));
Table created.
2 values(1,105,'pune',11);
1 row created.
2 values(2,102,'2nd floor',12);
1 row created.
2 values(3,103,'4th floor',13);
1 row created.
2 values(4,104,'1st floor',11);
1 row created.
2 values(5,101,'3rd floor',14);
1 row created.
COUNT(PATIENT06.PCODE)
----------------------
2 where patient06.pcode=bed06.pcode
3 and roomno=101;
NAME
--------------------
Sachin
2 where patient06.pcode=bed06.pcode
3 and bed_no = 1;
DISEASES
----------
ALLERGY
4. Display the room_no and bed_no of patient whose name is “Mr Roy”.
3 and name='Mr.Roy';
RoomNO Bed_no
---------- ---------
103 3
2 where patient06.pcode=bed06.pcode
2 where patient06.pcode=bed06.pcode
105 pune 11
Slip 5
Q3. Consider the following entities and their relationships. Create a RDB in 3 NF
with appropriate data types and Constraints.
Table created.
2 values(101,'Dhiraj','kharadi','pune');
1 row created.
2 values(102,'Patil','kalptaru','pimpri');
1 row created
2 values(103,'Abhay','west','pimpri');
1 row created.
2 values(104,'Raghav','rt','nashik');
1 row created.
2 values(105,'Dhanu','bvh','pune');
1 row created.
2 values(1,120000,101);
1 row created.
2 values(2,100000,102);
1 row created.
2 values(3,30000,103);
1 row created.
2 values(4,120000,104);
1 row created.
2 values(5,100000,105);
1 row created.
Table altered.
2 where customer06.cno=loan06.cno
3 and lamt>1000000;
No rows selected
3. List the names of customer in descending order who has taken a loan from
Pimpri city.
2 where city='pimpri'
2 where customer06.cno=loan06.cno;
MAX(LAMT)
----------
120000
5. Update the address of customer whose name is “Mr. Patil” and loan_amt is
3 where lno = 2;
1 row updated.
1 row updated.