0% found this document useful (0 votes)
13 views

ITDB Group Assignment 3

Uploaded by

i21sudhaharanh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

ITDB Group Assignment 3

Uploaded by

i21sudhaharanh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

ITDB Group Assignment 3

Integrated Programme in Management

Indian Institute of Management Indore

Group No.2

Aaryan Jalan
Anindya Sur
Anurag Chaudhari
Ritender S R
Shrey Syal
Sudhaharan H
Commands and Outputs for Creating the tables and inserting the values:
1. create database ITDBGA3;
Output:

2. use ITDBGA3;
Output:

3. create table Patient_Description1(PatientNo Integer, ItemCode integer, Description


Varchar(20),PRIMARY KEY(PatientNo,ItemCode));
Output after executing select statement:

4. insert into patient_description1 values(3249,200,'Room semi-pr');


insert into patient_description1 values(3249,205,'Television');
insert into patient_description1 values(3249,307,'X-ray');
insert into patient_description1 values(3249,413,'Lab Test');
insert into patient_description1 values(3250,405,'Tonsils Test');
insert into patient_description1 values(3250,414,'Diagnostic test');
insert into patient_description1 values(3250,508,'Vision Test');
insert into patient_description1 values(3250,625,'Hearing Test');
Output:

5. create table patient_items(itemcode integer references patient_Description1(itemcode), charge


numeric);
Output after executing select statement:

6. insert into patient_items values(200,150.00);


insert into patient_items values(205,10.00);
insert into patient_items values(307,25.00);
insert into patient_items values(413,225.00);
insert into patient_items values(414,110);
insert into patient_items values(405,205);
insert into patient_items values(500,250);
insert into patient_items values(625,125);
Output:

7. create table patient_details(patientname varchar(20) primary key, patientaddress


varchar(20),city_state_pin integer);
Output after executing select statement:

8. insert into patient_details values('C.V.S Rao', 'Hyderabad', 230445);


insert into patient_details values('Deshmukh','Mumbai',123544);
insert into patient_details values('Jamshed Kumar','Hyderabad',401233);
insert into patient_details values('K.M.Rao','Indore',425511);
insert into patient_details values('P.K.Mathur','Gwalior',561542);
insert into patient_details values('P.Sivastav','Telangana',202132);

Output:

9. create table patient_admdetails(patientname varchar(20) references


patient_details(patientname), patientno integer references patient_description1(patientno),
date_admitted date, date_discharged date, thirdparty varchar(50), location varchar(10)
references patient_loc_Details(location), patientaddress varchar(50) references
patient_Details(patientaddress));
Output after executing select statement:

10. insert into patient_admdetails values('C.V.S Rao',3249,'2003-09-18','2003-10-18','Juveline


Pvt.Ltd Secunderabad','437-2','300-A Sikander Street');
insert into patient_admdetails values('Jamshed Kumar',3250,'2003-10-18','2003-11-
18','Eveline Pvt.Ltd Secunderabad','437-3','21B R.K Street');
insert into patient_admdetails values('P.Sivastav',6083,'2003-11-18','2003-12-18','IT.Ltd
Jagtial','184-2','300 Gandhi Street');
insert into patient_admdetails values('P.K.Mathur',1239,'2003-09-27','2003-10-20','YT
Ltd','102-2','47 Cross Street');
insert into patient_admdetails values('K.M.Rao',4139,'2003-09-18','2003-10-18','MT.Pvt.Ltd
Mumbai','107-3','456-A SB Colony');
insert into patient_admdetails values('Deshmukh',5252,'2003-09-18','2003-10-18','JT Pvt.Ltd
Mumbai','528-2','225-B VT Colony');
Output:

11. create table room_uti_details(patientno integer references patient_description(patientno),


patientname varchar(20) references patient_details(patientname), exp_dischargedate date);
Output after executing select statement:

12. insert into room_uti_details values(6213, 'Yogeswar Murty', '1998-10-17');


insert into room_uti_details values(1379, 'Tejeswar Rao', '1998-10-15');
insert into room_uti_details values(1239, 'Aslam Khan', '1998-10-16');
insert into room_uti_details values(7040, 'Kimlla Rao', '1998-10-19');
insert into room_uti_details values(6083,'P.Sivastav','2003-12-20');
insert into room_uti_details values(5252,'Deshmukh','2003-12-20');
Output:

13. create table patient_loc_details(location varchar(10) primary key, accommodation


varchar(2));
Output after executing select statement:

14. insert into patient_loc_details values('100-1', 'PR');


insert into patient_loc_details values('100-2', 'PR');
insert into patient_loc_details values('100-3', 'SR');
insert into patient_loc_details values('100-4', 'SP');
insert into patient_loc_details values('100-5', 'PR');
Output:
15. create table location_Details(Dateofretrieval date, location varchar(10) references
patient_loc_Details(location), patientno integer references patient_description(patientno));
Output after executing select statement:

16. insert into location_details values('2003-10-15','100-1',6213);


insert into location_details values('2003-10-15','100-2',1379);
insert into location_details values('2003-10-15','100-3',NULL);
insert into location_details values('2003-10-15','100-4',1239);
insert into location_details values('2003-10-15','100-5',7040);
Output:

17. create table loc_extensiondetails(location varchar(10) references


patient_loc_Details(location), extension integer);
Output after executing select statement:

18. insert into loc_extensiondetails values('437-2',529);


insert into loc_extensiondetails values('184-2',528);
insert into loc_extensiondetails values('102-2',527);
insert into loc_extensiondetails values('107-3',526);
insert into loc_extensiondetails values('528-2',525);
insert into loc_extensiondetails values('426-1',524);
Output:

19. create table patient_addressdetails(patientaddress varchar(50) references


patient_Details(patientaddress), city_state_pin varchar(30));
Output after executing select statement:

20. insert into patient_addressdetails values('300-A Sikander Street','Hurli Road, PKS Street');
insert into patient_addressdetails values('21B R.K Street','HY Road,Guntur Street');
insert into patient_addressdetails values('52 S.S Street','Puram Road,TH Street');
insert into patient_addressdetails values('300 Gandhi Street','Agam Road,Glance Street');
insert into patient_addressdetails values('47 Cross Street','ULL Road,VT Street');
insert into patient_addressdetails values('456-A SB Colony','VELL Road,AG Street');
insert into patient_addressdetails values('225-B VT Colony','PUR Road,VE Street');
Output:

21. create table patient_physiciandetails(physicianID varchar(20), patientno integer references


patient_description(patientno),treatment_procedure varchar(25),primary key(patientno));
Output after executing select statement:

22. insert into patient_physiciandetails values('Iynegar',1239,'Observation');


insert into patient_physiciandetails values('Sandhan',3249,'Cardiology');
insert into patient_physiciandetails values('Sandhan',3250,'Hematology');
insert into patient_physiciandetails values('Iynegar',4139,'Chemotherapy');
insert into patient_physiciandetails values('Sandhan',5252,'Endocrinology');
insert into patient_physiciandetails values('Iynegar',6083,'Tonsillectomy');

Output:

23. create table physician_Details(physicianID varchar(20) references


patient_physiciandetails(physicianID), physician_phone varchar(20));

Output after executing select statement:


24. insert into physician_details values('Iynegar','329-1848');
insert into physician_details values('Sandhan','486-2256');
insert into physician_details values('Mathan','622-5485');
insert into physician_details values('Undeep','856-7626');
insert into physician_details values('Laletta','852-5626');
insert into physician_details values('Kethan','325-6523');
Output:

25. create table patient_dailyloc_details(patientno integer references


patient_description(patientno),patientname varchar(20) references
patient_details(patientname),location varchar(10) references
patient_loc_Details(location),present_date date);
Output:

26. insert into patient_dailyloc_details values(6083,'P.Sivastav','184-2','2003-10-17');


insert into patient_dailyloc_details values(1239,'P.K.Mathur','102-2','2003-10-17');
insert into patient_dailyloc_details values(4139,'K.M.Rao','107-3','2003-10-17');
insert into patient_dailyloc_details values(3250,'Jamshed Kumar','437-3','2003-12-17');
insert into patient_dailyloc_details values(3249,'C.V.S.Rao','426-1','2003-12-17');
insert into patient_dailyloc_details values(5252,'Deshmukh','528-2','2003-12-17');
Output:
SQL Queries on the created tables with the inserted values:
1. select * from patient_items where itemcode in (select itemcode from patient_description1
where patientno=3249);
Output:

2. select * from patient_description1 order by description;


Output:

3. select date_admitted,date_discharged from patient_admdetails where patientno=3249;


Output:

4. select patientaddress,city_state_pin from patient_details where patientname='C.V.S Rao';


Output:

5. update patient_dailyloc_details set patientname='C.V.S Rao' where patientname='C.V.S.Rao';


Output after using select statement:

6. select * from patient_loc_details;


Output:

7. select * from location_details where patientno=(select patientno from room_uti_details where


patientname='Yogeswar Murty');
Output:

8. update patient_loc_Details set accommodation='SP' where location='100-2';


Output after using select statement:

9. select * from location_details where patientno is null;


Output:

10. select patientname from room_uti_details where patientname like "%rao";


Output:

11. select * from patient_loc_Details group by accommodation;


Output:

12. select extension from loc_extensiondetails where location in('437-2','102-2','528-2');


Output:
13. select * from patient_admdetails where thirdparty like '%Hyderabad' or date_admitted='2003-
09-18';
Output:

14. select * from patient_admdetails where patientaddress like "%street%";


Output:

15. select patientname from patient_admdetails where location like "4%";


Output:

16. select * from loc_extensiondetails;


Output:

17. select patientname from room_uti_details where exp_dischargedate>"1998-10-16";


Output:

18. select patientname from room_uti_details order by patientname;


Output:
19. select location,patientno from location_details where patientno is not null;
Output:

20. create index loc_index on patient_loc_details(location);


Output:

21. desc patient_Admdetails;


Output:

22. show full columns from room_uti_details;


Output:

23. show create table patient_dailyloc_details;


Output:

24. select * from patient_description1 order by itemcode limit 3;


Output:
25. select physicianid from patient_physiciandetails where treatment_procedure='Tonsillectomy';
Output:

26. select patientno from patient_physiciandetails where treatment_procedure='Chemotherapy';


Output:

27. select patientname from patient_dailyloc_Details where patientno=(select patientno from


patient_physiciandetails where treatment_procedure='Observation');
Output:

28. update physician_details set physician_phone='328-1848' where physicianid='Iynegar';


Output after using select statement:

29. create index tele_index on physician_details(physician_phone);


Output:

30. select * from information_schema.columns where table_name='patient_admdetails';


Output:

31. delete from patient_description1 where description='Diagnostic Test';


Output after using select statement:

32. show tables;


Output:

33. select patientno from patient_dailyloc_Details where present_date='2003-12-17' and


location='528-2';
Output:

34. drop index tele_index on physician_details;


Output:

35. create view phy_procedure as select physicianid,treatment_procedure from


patient_physiciandetails;
Output:

36. select * from patient_admdetails order by patientno limit 4 offset 2;


Output:
37. select patientaddress,city_state_pin as second_address_line from patient_addressdetails;
Output:

38. select patient_physiciandetails.physicianid,patientno,physician_phone from


patient_physiciandetails LEFT JOIN physician_details on
patient_physiciandetails.physicianid=physician_details.physicianid;
Output:

39. select patient_dailyloc_details.patientno,patientname,treatment_procedure from


patient_dailyloc_details RIGHT JOIN patient_physiciandetails on
patient_dailyloc_details.patientno=patient_physiciandetails.patientno;
Output:

40. select * from patient_physiciandetails,patient_dailyloc_details where


patient_dailyloc_details.patientno=patient_physiciandetails.patientno;
Output:
41. create view patient_t_details as Select * from patient_admdetails;
Output:

42. update patient_physiciandetails set treatment_procedure='Hematology' where


patientno=1239;
Output:

43. alter table patient_admdetails modify patientaddress varchar(55);


Output:

44. select * from patient_description1 order by patientno,itemcode desc;


Output:

45. select sum(charge) as TotalVal_Services from patient_items;


Output:

46. select accommodation,count(location) from patient_loc_details group by accommodation;


Output:

47. select itemcode,charge*1.1 as increased_charge from patient_items;


Output:

48. alter table loc_extensiondetails change extension tele_extension varchar(20);


Output:

49. select * from patient_physiciandetails where treatment_procedure not


in('observation','hematology');
Output:

50. select itemcode,charge from patient_items where charge between 150 and 250;
Output:

51. alter table patient_items add column itemname varchar(10);


Output:

52. select distinct physicianid from patient_physiciandetails;


Output:

53. select * from patient_admdetails where date_discharged between '2003-10-20' and '2003-12-
18';
Output:
54. select patientname from patient_details where city_state_pin>300000;
Output:

55. alter table patient_items drop column itemname;


Output:

56. select patientname,thirdparty from patient_admdetails order by patientname;


Output:

57. select * from loc_extensiondetails where location like '%1';


Output:

58. select * from patient_physiciandetails group by physicianid, treatment_procedure;


Output:

59. select count(*) as Total_items,avg(charge) from patient_items;


Output:
60. select * from room_uti_details group by exp_dischargedate having exp_dischargedate>'1998-
10-17';
Output:

61. select * from location_details order by 2 desc;


Output:

62. select patientname,location from patient_dailyloc_Details where patientno in(select patientno


from patient_physiciandetails where physicianid=(select physicianid from physician_details
where physician_phone='329-1848'));
Output:

63. update patient_dailyloc_details set present_date='2004-10-17' where patientno=4139;


Output:

64. select * from patient_physiciandetails join patient_dailyloc_details on


patient_physiciandetails.patientno=patient_dailyloc_details.patientno;
Output:

65. alter table patient_loc_Details drop primary key;


Output:

66. explain select * from patient_Admdetails;


Output:

67. drop view patient_t_details;


Output:

68. select patientname from patient_Admdetails where date_discharged not between '2003-10-20'
and '2003-12-2003';
Output:

69. create procedure Addresses()


begin
select * from patient_addressdetails;
end$$
delimiter ;
Output after calling(call addresses()):

70. delete from physician_details;


Output:
Statement of Individual Contribution:
Ritender S R- Created all the tables, ensured referential integrity between attributes, added half
of the values for all the tables, came up with 42 out of the 70 queries on the tables with the
inserted values
Anurag Chaudhari- Helped in adding half of the values to the created tables, came up with 8
queries for the created tables
Shrey Syal, Sudhaharan, Aaryan Jalan, Anindya Sur- Came up with 5 queries each for the
created tables.

You might also like