Advertisement
Guest User

Untitled

a guest
May 7th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.44 KB | None | 0 0
  1. -- Table: Ambulance
  2. CREATE TABLE Ambulance
  3. (
  4. Ambulance_Id integer NOT NULL,
  5. Plaque_No varchar2(10) NOT NULL,
  6. CONSTRAINT Ambulance_pk PRIMARY KEY (Ambulance_Id)
  7. );
  8.  
  9. insert into Ambulance(Ambulance_Id, Plaque_No) values(1, '13AY755');
  10. insert into Ambulance(Ambulance_Id, Plaque_No) values(2, '06SAD23');
  11. insert into Ambulance(Ambulance_Id, Plaque_No) values(3, '06AY645');
  12.  
  13. select * from Ambulance;
  14.  
  15. -- Table: Appointment
  16. CREATE TABLE Appointment
  17. (
  18. Appointment_id integer NOT NULL,
  19. Department_name varchar2(50) NOT NULL,
  20. Doctor_Identify integer NOT NULL,
  21. Doctor_Gender varchar2(1) NOT NULL,
  22. Patient_number integer NOT NULL,
  23. Date_of_birth date NOT NULL,
  24. date_of_appointment date NOT NULL,
  25. Patient_complaint varchar(15) NOT NULL,
  26. CONSTRAINT Appointment_pk PRIMARY KEY (Appointment_id)
  27. );
  28.  
  29. insert into Appointment(Appointment_id, Department_name, Doctor_Identify, Doctor_Gender, Patient_number,Date_of_birth, date_of_appointment,Patient_complaint) values(1, 'otorhinolaryngology', 123456, 'M', 123123, DATE '1955-01-03', DATE '2019-05-07', 'Ear' );
  30. insert into Appointment(Appointment_id, Department_name, Doctor_Identify, Doctor_Gender, Patient_number,Date_of_birth, date_of_appointment,Patient_complaint) values(2, 'dietitian', 123426, 'W', 112123, DATE '1979-02-05', DATE '2019-12-06', 'Over-weight');
  31. insert into Appointment(Appointment_id, Department_name, Doctor_Identify, Doctor_Gender, Patient_number,Date_of_birth, date_of_appointment,Patient_complaint) values(3, 'otorhinolaryngology', 123154, 'M', 122312, DATE '1965-12-06', DATE '2019-12-10', 'Nose' );
  32.  
  33. select * from Appointment;
  34. --It will be show only man if I change m it will be show women
  35. select * from Appointment where Doctor_Gender = 'M';
  36.  
  37. -- Table: Hospital
  38. CREATE TABLE Hospital
  39. (
  40. Hospital_Id integer NOT NULL,
  41. eName varchar2(150) NOT NULL,
  42. Address varchar2(200) NOT NULL,
  43. Phone integer NOT NULL,
  44. Fax integer NOT NULL,
  45. Email varchar2(100) NOT NULL,
  46. Standart_room_number integer NOT NULL,
  47. Private_room_number integer NOT NULL,
  48. Ambulance_Ambulance_Id integer NULL,
  49. Room_info_id integer NULL,
  50. Personel_Info_Personal_Id integer NULL,
  51. Patient_info_id integer NULL,
  52. Appointment_Appointment_id integer NULL,
  53. CONSTRAINT Hospital_pk PRIMARY KEY (Hospital_Id)
  54. );
  55.  
  56. insert into Hospital (Hospital_Id, eName, Address, Phone, Fax, Email, Standart_room_number, Private_room_number) values (1, 'Gazi Hospital', 'xxxAddresxxx', 123123123, 123123, 'sdadada@gmail.com', 60,40);
  57. insert into Hospital (Hospital_Id, eName, Address, Phone, Fax, Email, Standart_room_number, Private_room_number) values (2, 'Hacettepe Hospital', 'xxxAddressxx', 123123123, 112123, 'sdadada@gmail.com', 70,50);
  58. insert into Hospital (Hospital_Id, eName, Address, Phone, Fax, Email, Standart_room_number, Private_room_number) values (3, 'Ankara university hospital','xxxAddressxx', 123123123, 122313, 'sdadada@gmail.com', 50,30);
  59.  
  60. select * from Hospital;
  61.  
  62. -- Table: Information_about_patient
  63. CREATE TABLE Information_about_patient
  64. (
  65. Patient_Id integer NOT NULL,
  66. Name_Surname varchar2(100) NOT NULL,
  67. Gender varchar2(15) NOT NULL,
  68. Hospital_Hospital_Id integer NULL,
  69. Ambulance_Ambulance_Id integer NULL,
  70. movement_information_Id integer NULL,
  71. Room_information_Id integer NULL,
  72. CONSTRAINT Information_about_patient_pk PRIMARY KEY (Patient_Id)
  73. );
  74.  
  75. insert into Information_about_patient (Patient_Id, Name_Surname, Gender) values(1, 'Clark', 'Man');
  76. insert into Information_about_patient (Patient_Id, Name_Surname, Gender) values(2, 'Emma', 'Women');
  77. insert into Information_about_patient (Patient_Id, Name_Surname, Gender) values(3, 'Emily', 'Women');
  78.  
  79. select * from Information_about_patient where Gender = 'Women';
  80.  
  81. -- Table: Patient_movement_information
  82. CREATE TABLE Patient_movement_information
  83. (
  84. Patient_move_info_Id integer NOT NULL,
  85. Made_operation varchar2(100) NOT NULL,
  86. Price integer NOT NULL,
  87. CONSTRAINT Patient_movement_informatio_pk PRIMARY KEY (Patient_move_info_Id)
  88. );
  89.  
  90. insert into Patient_movement_information(Patient_move_info_Id, Made_operation, Price) values(1, 'Test', 500);
  91. insert into Patient_movement_information(Patient_move_info_Id, Made_operation, Price) values(2, 'Surgery', 1000);
  92. insert into Patient_movement_information(Patient_move_info_Id, Made_operation, Price) values(3, 'Take blood', 300);
  93.  
  94. select * from Patient_movement_information;
  95. --when you want see max value from patient you have to use select max
  96. Select max(price) from Patient_movement_information;
  97. --when you want see mix value from patient you have to use select min
  98. Select min(price) from Patient_movement_information;
  99.  
  100. -- Table: Personel_Information
  101. CREATE TABLE Personel_Information
  102. (
  103. Personal_Id integer NOT NULL,
  104. Idenity_sumber integer NOT NULL,
  105. Name_surname varchar2(150) NOT NULL,
  106. Profession varchar2(150) NOT NULL,
  107. Start_date_to_job date NOT NULL,
  108. info_Patient_Id integer NULL,
  109. CONSTRAINT Personel_Information_pk PRIMARY KEY (Personal_Id)
  110. );
  111.  
  112. insert into Personel_Information(Personal_Id, Idenity_sumber, Name_surname, Profession, Start_date_to_job) values(1, 123456, 'Clark surname', 'Ear', DATE '2018-05-10');
  113. insert into Personel_Information(Personal_Id, Idenity_sumber, Name_surname, Profession, Start_date_to_job) values(2, 234562, 'Michal qwrewrx', 'Surgeon', DATE '2018-10-05');
  114. insert into Personel_Information(Personal_Id, Idenity_sumber, Name_surname, Profession, Start_date_to_job) values(3, 345614, 'Emma ewrrwx', 'Throat', DATE '2018-10-05');
  115.  
  116. select * from Personel_Information;
  117.  
  118. -- Table: Room_Information
  119. CREATE TABLE Room_Information
  120. (
  121. Room_information_Id integer NOT NULL,
  122. Bed_number integer NOT NULL,
  123. Private_room varchar2(10) NOT NULL,
  124. Standart_room varchar2(10) NOT NULL,
  125. Hospital_name varchar2(150) NOT NULL,
  126. CONSTRAINT Room_Information_pk PRIMARY KEY (Room_information_Id)
  127. );
  128.  
  129. insert into Room_Information(Room_information_Id, Bed_number, Private_room, Standart_room, Hospital_name) values(1, 2, 'No', 'Yes', 'Gazi Hospital');
  130. insert into Room_Information(Room_information_Id, Bed_number, Private_room, Standart_room, Hospital_name) values(2, 1, 'Yes', 'No', 'Hacettepe Hospital');
  131. insert into Room_Information(Room_information_Id, Bed_number, Private_room, Standart_room, Hospital_name) values(3, 2, 'No', 'Yes', 'Ankara university hospital');
  132.  
  133. select * from Room_Information;
  134.  
  135. -- foreign keys
  136. -- Reference: Hospital_Ambulance (table: Hospital)
  137. ALTER TABLE Hospital ADD CONSTRAINT Hospital_Ambulance
  138. FOREIGN KEY (Ambulance_Ambulance_Id)
  139. REFERENCES Ambulance (Ambulance_Id);
  140.  
  141. -- Reference: Hospital_Appointment (table: Hospital)
  142. ALTER TABLE Hospital ADD CONSTRAINT Hospital_Appointment
  143. FOREIGN KEY (Appointment_Appointment_id)
  144. REFERENCES Appointment (Appointment_id);
  145.  
  146. -- Reference: Hospital_Patient (table: Hospital)
  147. ALTER TABLE Hospital ADD CONSTRAINT Hospital_Patient
  148. FOREIGN KEY (Patient_info_id)
  149. REFERENCES Patient_movement_information (Patient_move_info_Id);
  150.  
  151. -- Reference: Hospital_Personel (table: Hospital)
  152. ALTER TABLE Hospital ADD CONSTRAINT Hospital_Personel
  153. FOREIGN KEY (Personel_Info_Personal_Id)
  154. REFERENCES Personel_Information (Personal_Id);
  155.  
  156. -- Reference: Hospital_Room (table: Hospital)
  157. ALTER TABLE Hospital ADD CONSTRAINT Hospital_Room
  158. FOREIGN KEY (Room_info_id)
  159. REFERENCES Room_Information (Room_information_Id);
  160.  
  161. -- Reference: Info_patient_Ambulance (table: Information_about_patient)
  162. ALTER TABLE Information_about_patient ADD CONSTRAINT Info_patient_Ambulance
  163. FOREIGN KEY (Ambulance_Ambulance_Id)
  164. REFERENCES Ambulance (Ambulance_Id);
  165.  
  166. -- Reference: Info_patient_Hospital (table: Information_about_patient)
  167. ALTER TABLE Information_about_patient ADD CONSTRAINT Info_patient_Hospital
  168. FOREIGN KEY (Hospital_Hospital_Id)
  169. REFERENCES Hospital (Hospital_Id);
  170.  
  171. -- Reference: Personel_Information (table: Personel_Information)
  172. ALTER TABLE Personel_Information ADD CONSTRAINT Personel_Information
  173. FOREIGN KEY (info_Patient_Id)
  174. REFERENCES Information_about_patient (Patient_Id);
  175.  
  176. -- Reference: patient_Room_info (table: Information_about_patient)
  177. ALTER TABLE Information_about_patient ADD CONSTRAINT patient_Room_info
  178. FOREIGN KEY (Room_information_Id)
  179. REFERENCES Room_Information (Room_information_Id);
  180.  
  181. -- Reference: patient_move_info (table: Information_about_patient)
  182. ALTER TABLE Information_about_patient ADD CONSTRAINT patient_move_info
  183. FOREIGN KEY (movement_information_Id)
  184. REFERENCES Patient_movement_information (Patient_move_info_Id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement