Advertisement
Guest User

Untitled

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