This database application is designed to manage the records and operations of a surgical department. It offers functionality to add and delete patients, surgeons, appointments, and operations, ensuring data integrity and consistency across the system. The application also handles key error cases to maintain the integrity of the database.
-
Add Patient
- Attributes:
patient_id
,first_name
,last_name
,birth_date
,gender
,address
,phone
- Attributes:
-
Delete Patient
- Allows deletion of patient records based on
patient_id
.
- Allows deletion of patient records based on
-
View Patient appoitment
- Allows viewing patient appointment based on
patient_id
.
- Allows viewing patient appointment based on
- Add Surgeon
- Attributes:
surgeon_id
,first_name
,last_name
,birth_date
,gender
,address
,phone
,email
- Attributes:
- Delete Surgeon
- Allows deletion of surgeon records based on
surgeon_id
.
- Allows deletion of surgeon records based on
- View Surgeon appointment
- Allows viewing of surgeon appointment based on
surgeon_id
.
- Allows viewing of surgeon appointment based on
- Add Appointment
- Attributes:
appointment_id
,patient_id
,surgeon_id
,operation_id
,appointments_date
,operationroom_id
- Attributes:
- Delete Appointment
- Allows deletion of appointment records based on
appointment_id
.
- Allows deletion of appointment records based on
- Add Operation
- Attributes:
operation_id
,operation
,description
,cost
- Attributes:
-
Unique IDs
- Error message raised if two patients, surgeons, or operations with the same ID are entered to ensure each ID is unique.
-
Appointment Conflicts
- Error message raised if attempting to enter two appointments at the same time for the same surgeon, patient, or operation room to avoid scheduling conflicts.
-
Foreign Key Integrity
- Error message raised if attempting to enter an appointment with a non-existent
surgeon_id
,patient_id
,operation_id
, oroperationroom_id
to ensure all referenced entities exist.
- Error message raised if attempting to enter an appointment with a non-existent
-
Cascade Deletion of Appointments
- Deleting an appointment for a surgeon will also update the database to delete the corresponding appointment for the patient and vice versa, ensuring the integrity of the appointment records.
To add a new patient:
INSERT INTO patients (patient_id, first_name, last_name, birth_date, gender, address, phone)
VALUES (...);
To delete a patient:
DELETE FROM patients WHERE patient_id = ...;
To add a new surgeon:
INSERT INTO surgeons (surgeon_id, first_name, last_name, birth_date, gender, address, phone, email)
VALUES (...);
To delete a surgeon:
DELETE FROM surgeons WHERE surgeon_id = ...;
To add a new appointment:
INSERT INTO appointments (appointment_id, patient_id, surgeon_id, operation_id, appointments_date, operationroom_id)
VALUES (...);
To delete an appointment:
DELETE FROM appointments WHERE appointment_id = ...;
To add a new operation:
INSERT INTO operations (operation_id, operation, description, cost)
VALUES (...);
- Duplicate IDs: Ensure unique IDs for patients, surgeons, and operations.
- Scheduling Conflicts: Avoid overlapping appointments for patients, surgeons, and operation rooms.
- Foreign Key Validation: Validate existence of referenced
surgeon_id
,patient_id
,operation_id
, andoperationroom_id
before adding an appointment. - Cascade Deletion: Deleting an appointment for a surgeon or patient will also delete the corresponding records to maintain database consistency.
This application provides a robust solution for managing the records and operations of a surgical department, ensuring data integrity and handling critical error cases effectively.