Rutvi Shah - 38 - B
Rutvi Shah - 38 - B
Rutvi Shah - 38 - B
Roll NO:38
NAME: Rutvi shah
Roll No: 38
Assignment: RDMS
SET-6
DOCTOR (DNO, DNAME, SPECIALIZATION, CLINIC_ADDR)
create table doctor (dno number (5) primary key, dname
varchar (20), SPECIALIZATION varchar (30), CLINIC_ADDR
varchar (30));
MEDICINE (MNO, MNAME, TYPE, CONTENT, MANUFACTURER)
CREATE TABLE MEDICINE (MNO VARCHAR(20) PRIMARY
KEY,MNAME VARCHAR(200) NOT NULL,TYPE VARCHAR(40) NOT
NULL,CONTENT VARCHAR(500) NOT NULL,MANUFACTURER
VARCHAR(100) NOT NULL);
DISEASE (DISEASE_NAME, SYMPTOM1, SYMPTOM2, SYMPTOM3)
CREATE TABLE DISEASE (DISEASE_NAME VARCHAR(100) NOT
NULL,SYMPTOM1 VARCHAR(40) NOT NULL,SYMPTOM2
VARCHAR(40) NOT NULL,SYMPTOM3 VARCHAR(40) NOT NULL);
TREATMENT (TNO, DNO, DISEASE_NAME, MNO, DOSAGE,
AVG_CURE_TIME)
CREATE TABLE TREATMENT (TNO INT PRIMARY KEY,DNO INT
REFERENCES doctor(DNO) ,DISEASE_NAME VARCHAR(100)
REFERENCES disease(DISEASE_NAME),MNO VARCHAR(20)
REFERENCES medicine(MNO),DOSAGE int NOT
NULL,AVG_CUR_TIME int NOT NULL);
Do as directed:
DNO DNAME
---------- --------------------------------------------------
1 dr.heena
8. What is the maximum dosage of “penicillin” prescribe by the doctor
for the treatment of any disease?
select max(dosage) from treatment where mno = (select mno
from medicine where mname = 'penicilline');
MAX(DOSAGE)
-----------
3
9. Display total number of disease treated by every doctor.
select count(dno) from treatment;
COUNT(DNO)
----------
5
10.Which doctor have no treatment for “depression”?
select * from doctor where dno not in (select dno from
treatment where disease_name='depression');
DNO DNAME
---------- --------------------------------------------------
SPECILIZATION
--------------------------------------------------
CLINIC_ADDR
--------------------------------------------------
1 dr.prakash
cancer
meghaninagar
NAME: Rutvi Shah
Roll NO:38
3 dr.heena
depression
gandhinagar
DNO DNAME
---------- --------------------------------------------------
SPECILIZATION
--------------------------------------------------
CLINIC_ADDR
--------------------------------------------------
11.Create a view which contains the treatment and doctors details.
Make sure that no body is allowed to modify any detail in the view.
View created
12.Write a PL/SQL block to print the following report (Symptoms wise
print total number of medicine given)
DECLARE
CURSOR symptom_cursor IS
SELECT MNAME, SYMPTOM1, SYMPTOM2, SYMPTOM3, COUNT(*) AS total
FROM MEDICINE
INNER JOIN TREATMENT ON MEDICINE.MNO = TREATMENT.MNO
INNER JOIN DISEASE ON TREATMENT.DISEASE_NAME = DISEASE.DISEASE_NAME
GROUP BY MNAME, SYMPTOM1, SYMPTOM2, SYMPTOM3;
BEGIN
END LOOP;
END;
NAME: Rutvi Shah
Roll NO:38
/
13)Write a trigger which does not allow to insert or update treatment table if
AVG_CURE_TIME is less than 1.
CREATE OR REPLACE TRIGGER prevent_low_cure_time
BEFORE INSERT OR UPDATE ON TREATMENT
FOR EACH ROW
BEGIN
IF: NEW.AVG_CURE_TIME < 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'AVG_CURE_TIME must
be at least 1');
END IF;
END;
/
NAME: Rutvi Shah
Roll NO:38
SET-7
insert into
customer(cno,cust_name,cust_phone,location,gender) values
insert into
item(itemno,itemname,color,weight,expire_date,price,shop)
values
insert into
cust_item(cno,itemno,quantity_purchased,date_purchase)
values
Do as directed:
20 jacket brown
14 22-oct-22 7000
dmart
20 jacket brown
14 22-oct-22 7000
dmart
2 nisha 9586095100
meghaninagar female
coffee 5
3 akansha 9979779955
gandhinagar female
bag 7
4 nikunj 4567891230
bapunagar male
5 janki 1234567890
bapunagar female
purse
NAME: Rutvi Shah
Roll NO:38
SET-8
SCREEN (SCREEN_ID, LOCATION, SEATING_CAP)
create table customer(cno number(5) primary
key,cust_phone number(10),location varchar(20),gender
varchar(7),cus_name varchar(20));
MOVIE (MOVIE_ID, MOVIE_NAME, DATE_OF_RELEASE)
create table item(itemno number(5) primary key,itemname
varchar(20),color varchar(7),weight number(10)
check(weight>0),expire_date date,price number(5)
check(price>0) not null,shop_name varchar(20));
CURRENT (SCREEN_ID, MOVIE_ID, DATE_OF_ARRIVAL,
DATE_OF_CLOSURE)
create table cust_item(cno number(5),foreign key(cno)
references customer(cno),itemno number(5),foreign
key(itemno) references item(itemno),
quantity_purchases number (5), date_purchases date);
Do as directed:
1. Get the name of movie which has run the longest in the
multiplex so far.
select moviel. movieid, moviel. mane from moviel, current1 where
moviel. movie id-current1.movieid and (DOC-DOA) in (select max (DOC-
DOA) from current1);
movieid mane
-----------------------------
5 idiot
NAME: Rutvi Shah
Roll NO:38
2. Get the average duration of a movie on screen number
‘S4’.
select avg (DOC-DOA) as average duration from current where currentl.
scri
average duration
85.0000
3. Get the details of movie that closed on date 24-
november-2004.
select from moviel, current where current1.movieid-moviel. movieid
and OC-2004-09-10";
S3 tf 120 s3 3 2022-06-25
2022-07-10
S4 ff 200 s4 4 2020-01-25
2020-02-10
S5 sf 234 s5 5 2019-02-07
2019-03-10
COUNT(DATE_OF_ARRIVEL-DATE_OF_RELEASE)
-------------------------------------------------------------------
30
7. Write a PL/SQL procedure that will display movie
which is going to release today.
select (date_of_closure - date_of_arrival) into day from cur where
movie_id = (select movie_id from movie where movie_name = 'horror');
return day;
end;
/
declare
c number;
begin
c:= da();
dbms_output.put_line('days: ' || c);
end;
/
DO as directed:
11.Display details about applicants who appeared for tests in the same
month as the month in which they were born.
select aid, aname from applicant where aid in (select a.aid
from applicant a, etest_details ed where to_char (a.abirth_dt,
'mon') = to_char (ed.etest_dt, 'mon'));
AID ANAME
---- --------------------
A1 jayesh
A3 rajvi
12.Display the details about APPLICANTS who have scored the highest
in each test, test centre wise.
select ed.etid, ed.etcid, max(score) from etest_details ed
group by ed.etid, ed.etcid order by etid;
ETID ETCID MAX(SCORE)
---------- ---------- -----------------------
1 11 90
2 22 150
13.Design a read only view, which has details about applicants and the
tests that he has appeared for.
create or replace view view1 as select a.aid, aname, et.etid,
et.etname from applicant a, etest_details ed, entrance_test et
where a.aid = ed.aid and et.etid=ed.etid with read only;
View created.
Procedure created.
COUNT(C.CATDESC)
-------------------------------
1
1
1
1
6. Write a trigger which allow to insert or update the bus capacity only
greater than zero and less than 60.
7. Write a Procedure which will print tour details, a driver is going to take it.
(Pass routeno as parameter)