All our Medlink applications will connect to a MySQL database where all project data is gathered and managed. For this project, we will be using MySQL Workbench for designing and managing the database.
[x] 1. Create script of TABLES based on the designed diagram. If script is autogenerated, check whether is properly created. If not, make some changes.
Base fields: treatment_id, medicine_id, quantity_per_day, total_quantity, unit_of_measure_id.
Primary key is treatment_id + medicine_id.
For quantities fields, we use FLOAT but we should round or trucate doses to make it easier for us when we need to calculate quantity_per_day field. We follow this round rules: (>=0,25)&(<0,50) equals 0,25 | (=0,5) equals 0,5 | (>=0,75)&(<=1) equals 1.
6. _Unit_OfMeasure.
Base fields: id, name, abbreviation.
Name and Abbreviation fields are UNIQUE.
7. _MedicineCategory.
Base fields: id, name, desc.
Medicine categories are added to the DB by manual INSERT. There is no need to develop CRUD functionalities for managing the medicine categories used in our apps.
8. _MedicalSpecialty.
Base fields: id, name.
Specialties are added to the DB by manual INSERT. There is no need to develop CRUD functionalities for managing the specialties used in our apps.
Observations.
⚠ For DATE CONSTRAINTS, instead of CHECK we will be using TRIGGERS. With MySQL 8.0.13+ versions, you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. ⚠
MySQL Medlink Database
All our Medlink applications will connect to a MySQL database where all project data is gathered and managed. For this project, we will be using MySQL Workbench for designing and managing the database.
Database diagram.
Reference model:
Generate DB scripts from previous diagram.
[x] 1. Create script of TABLES based on the designed diagram. If script is autogenerated, check whether is properly created. If not, make some changes.
[x] 2. Import script and create schema with its tables in MySQL Database.
[x] 3. Create INSERT scripts for:
[x] Specialty. SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/specialites/INSERT_specialites.sql
[x] Medicine_Category. SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/medicines/INSERT_medicine_category.sql
[x] Medicine. SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/medicines/INSERT_medicines.sql
[x] Treatment. SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/treatments/INSERT_treatments.sql
[x] Treatment_Medicine. SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/treatment_medicine/INSERT_treatment_medicine.sql
[x] Unit_Of_Measure. SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/units_of_measure/INSERT_units_of_measure.sql
[x] Person (Person). SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/people%20(person)/person/INSERT_person.sql
[x] Patient (Person). SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/people%20(person)/patient/INSERT_patient.sql
[x] Doctor (Person). SQL Script: https://github.com/polivagit/Medlink/blob/main/MySQL_Medlink/Guions/people%20(person)/doctor/INSERT_doctor.sql
[x] 3.1. Merge ALL INSERT scripts into a single script.
Tables: Guidelines & definitions.
1. Person.
2.1. [Person] Patient.
2.2. [Person] Doctor.
3. Treatment.
4. Medicine.
5. _[Treatment - Medicine, (N:M)] TreatmentMedicine.
6. _Unit_OfMeasure.
7. _MedicineCategory.
8. _MedicalSpecialty.
Observations.
⚠ For DATE CONSTRAINTS, instead of CHECK we will be using TRIGGERS. With MySQL 8.0.13+ versions, you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. ⚠
Fields affected by this issue: