Changes between Version 3 and Version 4 of ERModel


Ignore:
Timestamp:
11/29/26 19:07:55 (6 hours ago)
Author:
211085
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ERModel

    v3 v4  
    44
    55[[Image(ERModel_v01.png, 2000px)]]
     6
     7== Data requirements ==
     8
     9=== Entities ===
     10
     11'''`Donor`'''
     12
     13The `Donor` entity represents individuals registered in the system who can participate in blood donation activities. It is modeled separately because donors can have multiple appointments and donations over time, while their personal identity remains the same regardless of the number of donation activities they participate in.
     14
     15'''Candidate keys:'''
     16 * `donor_id` – Primary key. It uniquely identifies each donor and is selected as the system's internal identifier.
     17 * `embg` – Alternative candidate key, since every citizen has a unique EMBG.
     18`donor_id` is chosen as the primary key because `embg` is sensitive personal data that should not be repeated as a key in other tables, and a foreign donor may not have one.
     19
     20'''Attributes:'''
     21 * `donor_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     22 * `embg` – Text (CHAR(13)), required, unique, exactly 13 numeric digits.
     23 * `full_name` – Composite attribute consisting of:
     24   * `first_name` – Text (VARCHAR), required, non-empty first name.
     25   * `last_name` – Text (VARCHAR), required, non-empty last name.
     26 * `date_of_birth` – Date (DATE), required, valid date that cannot be in the future.
     27 * `age` – Numeric (INTEGER), derived from `date_of_birth` and the current date.
     28 * `gender` – Text (VARCHAR), required, one of: `M`, `F`.
     29 * `phone` – Text (VARCHAR), multivalued, stores one or more valid telephone numbers.
     30 * `email` – Text (VARCHAR), optional, must follow a valid email address format.
     31 * `address` – Composite attribute consisting of:
     32   * `street` – Text (VARCHAR), required, street and street number.
     33   * `city` – Text (VARCHAR), required, city of residence.
     34 * `deferred_until` – Date (DATE), optional, indicates the date until which the donor is temporarily deferred.
     35 * `deferral_reason` – Text (TEXT), optional, describes the reason for donor deferral. It should be provided when a deferral is recorded.
     36
     37----
     38'''`BloodGroup`'''
     39
     40The `BloodGroup` entity represents the different blood groups recognized by the system, based on the ABO and Rh classifications. It is modeled as a separate entity because blood group information is shared by donors, patients, and collected blood units. Centralizing this information also allows the system to define compatibility rules between different blood groups and component types.
     41
     42'''Candidate keys:'''
     43 * `bg_id` – Primary key. It uniquely identifies each blood group.
     44 * (`abo_type`, `rh_factor`) – Alternative composite candidate key, since each combination appears only once.
     45`bg_id` is chosen as the primary key because a single short key is simpler to use in the many relationships connected to blood groups than a pair of attributes.
     46
     47'''Attributes:'''
     48 * `bg_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     49 * `abo_type` – Text (VARCHAR), required, restricted to `A`, `B`, `AB`, or `O`.
     50 * `rh_factor` – Text (VARCHAR), required, restricted to positive or negative Rh factor (`+` or `-`).
     51
     52----
     53'''`TransfusionCenter`'''
     54
     55The `TransfusionCenter` entity represents the facilities responsible for organizing blood donation campaigns and providing blood transfusion services. It is modeled independently because the system can manage multiple transfusion centers, each operating with its own campaigns, appointments, and employees.
     56
     57'''Candidate keys:'''
     58 * `center_id` – Primary key. It uniquely identifies each transfusion center.
     59
     60'''Attributes:'''
     61 * `center_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     62 * `name` – Text (VARCHAR), required, non-empty name of the transfusion center.
     63 * `phone` – Text (VARCHAR), required, valid telephone number, preferably including the international country code.
     64 * `address` – Composite attribute consisting of:
     65   * `street` – Text (VARCHAR), required, street and street number.
     66   * `city` – Text (VARCHAR), required, city in which the center is located.
     67
     68----
     69'''`Campaign`'''
     70
     71The `Campaign` entity represents organized blood donation campaigns conducted by transfusion centers. It is modeled as a separate entity because a transfusion center can organize multiple campaigns, and each campaign can have multiple appointments associated with it. This separation allows campaigns and their associated appointments to be managed independently.
     72
     73'''Candidate keys:'''
     74 * `campaign_id` – Primary key. It uniquely identifies each campaign and is selected because it is independent of the campaign's name, location, and date.
     75
     76'''Attributes:'''
     77 * `campaign_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     78 * `name` – Text (VARCHAR), required, non-empty campaign name.
     79 * `location` – Text (VARCHAR), required, describes the campaign location.
     80 * `campaign_date` – Date (DATE), required, valid calendar date.
     81
     82----
     83'''`Appointment`'''
     84
     85The `Appointment` entity represents a scheduled visit by a donor to a transfusion center for a potential blood donation. It is modeled separately from `Donation` because scheduling an appointment does not necessarily mean that a donation will take place. This distinction allows the system to manage scheduled visits independently of completed donation procedures.
     86
     87'''Candidate keys:'''
     88 * `appointment_id` – Primary key. It uniquely identifies each appointment.
     89
     90'''Attributes:'''
     91 * `appointment_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     92 * `date_time` – Date and time (TIMESTAMP), required, valid date and time for the scheduled appointment.
     93
     94----
     95'''`Employee`'''
     96
     97The `Employee` entity represents personnel employed by a transfusion center. It serves as a general entity for the different professional roles within the center. It is specialized into `Doctor`, `Nurse`, and `LabTechnician` because these roles share common employee characteristics but have different professional responsibilities and additional role-specific attributes.
     98
     99The specialization is disjoint, as indicated by the `d` notation in the ER diagram, and total, because every employee has exactly one of these roles.
     100
     101'''Candidate keys:'''
     102 * `employee_id` – Primary key. It uniquely identifies each employee.
     103 * `embg` – Alternative candidate key, since every citizen has a unique EMBG.
     104`employee_id` is chosen as the primary key because `embg` is sensitive personal data that should not be repeated as a key in other tables.
     105
     106'''Attributes:'''
     107 * `employee_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     108 * `embg` – Text (CHAR(13)), required, unique, exactly 13 numeric digits.
     109 * `full_name` – Composite attribute consisting of:
     110   * `first_name` – Text (VARCHAR), required, non-empty first name.
     111   * `last_name` – Text (VARCHAR), required, non-empty last name.
     112 * `phone` – Text (VARCHAR), required, valid telephone number.
     113 * `hire_date` – Date (DATE), required, valid employment date.
     114
     115----
     116'''`Doctor`'''
     117
     118The `Doctor` entity represents employees who have the professional role of a doctor within a transfusion center. It is modeled as a specialization of `Employee` because doctors inherit the common employee characteristics while having additional information specific to their medical qualifications and professional responsibilities.
     119
     120'''Candidate keys:'''
     121 * `employee_id` – Primary key, inherited from `Employee`.
     122 * `license_no` – Alternative candidate key, provided that professional license numbers are unique.
     123The inherited `employee_id` is selected as the primary key to maintain the identification of the doctor in relation to the general `Employee` entity.
     124
     125'''Attributes:'''
     126 * `employee_id` – Numeric (BIGINT), required, inherited from `Employee` and references the corresponding employee.
     127 * `license_no` – Text (VARCHAR), required, unique professional license number.
     128 * `specialty` – Text (VARCHAR), required, medical specialty of the doctor.
     129
     130----
     131'''`Nurse`'''
     132
     133The `Nurse` entity represents employees responsible for nursing activities within a transfusion center, particularly during blood donation procedures. It is modeled as a specialization of `Employee` because nurses share the common employee characteristics but have additional information related to their specific professional role.
     134
     135'''Candidate keys:'''
     136 * `employee_id` – Primary key, inherited from `Employee`.
     137
     138'''Attributes:'''
     139 * `employee_id` – Numeric (BIGINT), required, inherited from `Employee` and references the corresponding employee.
     140 * `shift` – Text (VARCHAR), required, the nurse's assigned work shift, one of: `morning`, `afternoon`, `night`.
     141
     142----
     143'''`LabTechnician`'''
     144
     145The `LabTechnician` entity represents employees responsible for laboratory activities, including testing blood units and handling discarded components. It is modeled as a specialization of `Employee` because laboratory technicians share common employee characteristics but have additional professional qualifications and responsibilities specific to laboratory work.
     146
     147'''Candidate keys:'''
     148 * `employee_id` – Primary key, inherited from `Employee`.
     149
     150'''Attributes:'''
     151 * `employee_id` – Numeric (BIGINT), required, inherited from `Employee` and references the corresponding employee.
     152 * `certification` – Text (VARCHAR), required, certification or professional qualification held by the laboratory technician.
     153
     154----
     155'''`Donation`'''
     156
     157The `Donation` entity represents an individual blood donation performed by a donor. It is modeled independently because each donation is a separate medical and operational event, even when the same donor participates multiple times. This allows each donation to be associated with its corresponding examination, blood collection procedure, and resulting blood unit.
     158
     159'''Candidate keys:'''
     160 * `donation_id` – Primary key. It uniquely identifies each donation.
     161
     162'''Attributes:'''
     163 * `donation_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     164 * `donated_at` – Date and time (TIMESTAMP), required, records when the donation took place; cannot be in the future.
     165 * `body_temperature` – Numeric (DECIMAL), required, body temperature measured in degrees Celsius; must be between 34.0 and 42.0.
     166 * `weight_kg` – Numeric (DECIMAL), required, donor's measured weight in kilograms; must be between 30 and 250.
     167 * `blood_pressure` – Text (VARCHAR), required, records blood pressure in a standardized systolic/diastolic format, for example 120/80 mmHg. The systolic value must be between 60 and 250, the diastolic value between 30 and 150, and the diastolic value must be lower than the systolic.
     168 * `hemoglobin` – Numeric (DECIMAL), required, hemoglobin measurement in g/dL; must be between 5.0 and 25.0.
     169 * `pulse` – Numeric (INTEGER), required, pulse measured in beats per minute; must be between 30 and 220.
     170
     171----
     172'''`BloodUnit`'''
     173
     174The `BloodUnit` entity represents a collected unit of whole blood obtained from a donation. It is modeled separately from `Donation` because the collected blood unit becomes an individual object that can be identified, tested, stored, and subsequently separated into different blood components. This distinction allows the system to track the blood unit throughout its lifecycle.
     175
     176'''Candidate keys:'''
     177 * `unit_id` – Primary key. It uniquely identifies each blood unit.
     178 * `barcode` – Alternative candidate key, since every bag carries a unique barcode.
     179`unit_id` is chosen as the primary key because it is a short internal number, while the barcode is a longer text whose format depends on the labeling equipment.
     180
     181'''Attributes:'''
     182 * `unit_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     183 * `barcode` – Text (VARCHAR), required, unique barcode used to identify and track the blood unit. It may contain numeric and alphanumeric characters.
     184 * `volume_ml` – Numeric (DECIMAL), required, volume of collected blood in milliliters; must be greater than zero and at most 600.
     185
     186----
     187'''`TestType`'''
     188
     189The `TestType` entity represents the different laboratory tests that can be performed on collected blood units. It is modeled separately from the actual testing operations because the definition of a test is independent of the individual blood units on which that test is performed. This allows the same test types to be reused for multiple blood units.
     190
     191'''Candidate keys:'''
     192 * `test_type_id` – Primary key. It uniquely identifies each test type.
     193
     194'''Attributes:'''
     195 * `test_type_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     196 * `name` – Text (VARCHAR), required, non-empty name of the test.
     197 * `is_mandatory` – Boolean, required, indicates whether the test is mandatory. Allowed values are `TRUE` or `FALSE`.
     198
     199----
     200'''`Component`'''
     201
     202The `Component` entity represents an individual blood component obtained by separating a collected blood unit. It is modeled separately from `BloodUnit` because a single blood unit can produce multiple components, each of which can have its own storage conditions, expiration date, allocation, and transfusion history. It is modeled as a weak entity of `BloodUnit`, because a component cannot exist without the unit it was separated from and is identified only within that unit.
     203
     204'''Candidate keys:'''
     205 * (`unit_id`, `component_no`) – Primary key, formed by the identifier of the owning blood unit together with the partial key `component_no`.
     206
     207'''Attributes:'''
     208 * `component_no` – Numeric (INTEGER), required, partial key, unique within its blood unit, starting from 1.
     209 * `produced_at` – Date and time (TIMESTAMP), required, records when the component was produced.
     210 * `volume_ml` – Numeric (DECIMAL), required, component volume in milliliters; must be greater than zero.
     211 * `expiry_date` – Date (DATE), derived attribute, calculated using the production date and the shelf life associated with the component type.
     212
     213----
     214'''`ComponentType`'''
     215
     216The `ComponentType` entity represents the different categories of blood components managed by the system. It is modeled separately from `Component` because multiple individual components can belong to the same type and share the same storage requirements, temperature limits, and shelf life.
     217
     218'''Candidate keys:'''
     219 * `ct_id` – Primary key. It uniquely identifies each component type.
     220
     221'''Attributes:'''
     222 * `ct_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     223 * `name` – Text (VARCHAR), required, non-empty name of the component type.
     224 * `shelf_life_days` – Numeric (INTEGER), required, shelf life expressed in days; must be greater than zero.
     225 * `storage_temp` – Composite attribute consisting of:
     226   * `min_temp` – Numeric (DECIMAL), required, minimum permitted storage temperature in degrees Celsius.
     227   * `max_temp` – Numeric (DECIMAL), required, maximum permitted storage temperature in degrees Celsius; must be greater than `min_temp`.
     228
     229----
     230'''`Hospital`'''
     231
     232The `Hospital` entity represents healthcare institutions that request blood components for their patients. It is modeled separately because a hospital can submit multiple blood requests and treat multiple patients, while remaining an independent institution within the system.
     233
     234'''Candidate keys:'''
     235 * `hospital_id` – Primary key. It uniquely identifies each hospital.
     236
     237'''Attributes:'''
     238 * `hospital_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     239 * `name` – Text (VARCHAR), required, non-empty hospital name.
     240 * `phone` – Text (VARCHAR), required, valid telephone number.
     241 * `address` – Composite attribute consisting of:
     242   * `street` – Text (VARCHAR), required, street and street number.
     243   * `city` – Text (VARCHAR), required, city in which the hospital is located.
     244
     245----
     246'''`BloodRequest`'''
     247
     248The `BloodRequest` entity represents a request submitted by a hospital for blood components needed by its patients. It is modeled separately because each request is an individual process that must be tracked independently, from its submission and allocation of available components to its eventual fulfillment.
     249
     250'''Candidate keys:'''
     251 * `request_id` – Primary key. It uniquely identifies each blood request.
     252
     253'''Attributes:'''
     254 * `request_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     255 * `created_at` – Date and time (TIMESTAMP), required, records when the request was created.
     256 * `urgency` – Text (VARCHAR), required, one of: `routine`, `urgent`, `emergency`.
     257
     258----
     259'''`Patient`'''
     260
     261The `Patient` entity represents individuals who require blood transfusions. It is modeled as a separate entity because a patient can have multiple blood requests and receive multiple transfusions over time. Keeping patient information independent of individual requests and transfusions allows the system to maintain a consistent record of each patient throughout their treatment.
     262
     263'''Candidate keys:'''
     264 * `patient_id` – Primary key. It uniquely identifies each patient.
     265`embg` is not a candidate key, because it may be missing when a patient is admitted in an emergency. It is unique only when it is entered.
     266
     267'''Attributes:'''
     268 * `patient_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     269 * `embg` – Text (CHAR(13)), optional, exactly 13 numeric digits when entered, unique.
     270 * `full_name` – Composite attribute consisting of:
     271   * `first_name` – Text (VARCHAR), required, non-empty first name.
     272   * `last_name` – Text (VARCHAR), required, non-empty last name.
     273 * `date_of_birth` – Date (DATE), required, valid date that cannot be in the future.
     274
     275----
     276'''`Transfusion`'''
     277
     278The `Transfusion` entity represents an actual blood transfusion administered to a patient. It is modeled separately from `BloodRequest` because submitting a request and performing a transfusion are two different processes. A request may be fulfilled later, and a patient can receive multiple transfusions over time. This entity also allows the system to maintain an individual record of each transfusion procedure.
     279
     280'''Candidate keys:'''
     281 * `transfusion_id` – Primary key. It uniquely identifies each transfusion.
     282
     283'''Attributes:'''
     284 * `transfusion_id` – Numeric (BIGINT), required, automatically generated, positive and unique.
     285 * `transfused_at` – Date and time (TIMESTAMP), required, records when the transfusion took place.
     286 * `reaction` – Text (VARCHAR), required, the reaction observed during or after the transfusion, one of: `none`, `mild`, `moderate`, `severe`. The default value is `none`.
     287
     288----
     289=== Relationships ===
     290
     291'''`has_group`'''
     292
     293The `has_group` relationship connects `Donor` and `BloodGroup`. It associates each donor with their blood group. It is modeled as a one-to-many relationship because multiple donors can share the same blood group, while each donor has at most one recorded blood group.
     294
     295'''Cardinality:''' `BloodGroup` (1) : `Donor` (N).
     296
     297'''Relationship attributes:''' None.
     298
     299----
     300'''`works_at`'''
     301
     302The `works_at` relationship connects `Employee` and `TransfusionCenter`. It represents the employment relationship between personnel and their respective transfusion centers. It is modeled as a one-to-many relationship because one transfusion center can employ multiple employees, while each employee is associated with one center.
     303
     304'''Cardinality:''' `TransfusionCenter` (1) : `Employee` (N).
     305
     306'''Relationship attributes:''' None.
     307
     308----
     309'''`organizes`'''
     310
     311The `organizes` relationship connects `Campaign` and `TransfusionCenter`. It represents the responsibility of a transfusion center for organizing blood donation campaigns. It is modeled as a one-to-many relationship because one transfusion center can organize multiple campaigns, while each campaign is organized by one transfusion center.
     312
     313'''Cardinality:''' `TransfusionCenter` (1) : `Campaign` (N).
     314
     315'''Relationship attributes:''' None.
     316
     317----
     318'''`books`'''
     319
     320The `books` relationship connects `Donor` and `Appointment`. It represents the association between a donor and their scheduled appointments. It is modeled as a one-to-many relationship because one donor can book multiple appointments over time, while each appointment is booked by one donor.
     321
     322'''Cardinality:''' `Donor` (1) : `Appointment` (N).
     323
     324'''Relationship attributes:''' None.
     325
     326----
     327'''`for_campaign`'''
     328
     329The `for_campaign` relationship connects `Campaign` and `Appointment`. It associates appointments with the campaigns for which donors have registered. It is modeled as a one-to-many relationship because one campaign can have multiple appointments, while each appointment belongs to at most one campaign.
     330
     331'''Cardinality:''' `Campaign` (1) : `Appointment` (N).
     332
     333'''Relationship attributes:''' None.
     334
     335----
     336'''`at_center`'''
     337
     338The `at_center` relationship connects `Appointment` and `TransfusionCenter`. It identifies the transfusion center at which an appointment is scheduled to take place. It is modeled as a one-to-many relationship because one transfusion center can host multiple appointments, while each appointment takes place at one center.
     339
     340'''Cardinality:''' `TransfusionCenter` (1) : `Appointment` (N).
     341
     342'''Relationship attributes:''' None.
     343
     344----
     345'''`gives`'''
     346
     347The `gives` relationship connects `Donor` and `Donation`. It represents the association between a donor and the blood donations they make. It is modeled as a one-to-many relationship because one donor can make multiple donations over time, while each donation is associated with one donor.
     348
     349'''Cardinality:''' `Donor` (1) : `Donation` (N).
     350
     351'''Relationship attributes:''' None.
     352
     353----
     354'''`from_appointment`'''
     355
     356The `from_appointment` relationship connects `Appointment` and `Donation`. It records which appointment resulted in a particular blood donation. It is modeled as a one-to-one relationship because an appointment can result in at most one donation, and a donation can come from at most one appointment.
     357
     358'''Cardinality:''' `Appointment` (1) : `Donation` (1).
     359
     360'''Relationship attributes:''' None.
     361
     362----
     363'''`examined_by`'''
     364
     365The `examined_by` relationship connects `Donation` and `Doctor`. It identifies the doctor responsible for examining the donor during the donation procedure. It is modeled as a one-to-many relationship because one doctor can examine multiple donations, while each donation is examined by one doctor.
     366
     367'''Cardinality:''' `Doctor` (1) : `Donation` (N).
     368
     369'''Relationship attributes:''' None.
     370
     371----
     372'''`performed_by`'''
     373
     374The `performed_by` relationship connects `Donation` and `Nurse`. It identifies the nurse responsible for performing the blood collection procedure. It is modeled as a one-to-many relationship because one nurse can perform multiple donations, while each donation is performed by one nurse.
     375
     376'''Cardinality:''' `Nurse` (1) : `Donation` (N).
     377
     378'''Relationship attributes:''' None.
     379
     380----
     381'''`produces`'''
     382
     383The `produces` relationship connects `Donation` and `BloodUnit`. It represents the production of a collected blood unit as the result of a donation. It is modeled as a one-to-one relationship because each donation produces at most one blood unit, and each blood unit originates from one donation.
     384
     385'''Cardinality:''' `Donation` (1) : `BloodUnit` (1).
     386
     387'''Relationship attributes:''' None.
     388
     389----
     390'''`tested`'''
     391
     392The `tested` relationship connects `TestType`, `LabTechnician`, and `BloodUnit`. It represents a laboratory testing operation performed on a blood unit by a laboratory technician using a particular test type. It is modeled as a ternary relationship because all three entities are needed to describe a testing operation. This makes it possible to associate each test result with the corresponding blood unit, test type, and responsible technician.
     393
     394'''Cardinality:''' `TestType` (M) : `BloodUnit` (N) : `LabTechnician` (1). A specific test on a specific blood unit is performed by one laboratory technician.
     395
     396'''Relationship attributes:'''
     397 * `result` – Text (VARCHAR), required, the outcome of the performed test, one of: `positive`, `negative`.
     398 * `tested_at` – Date and time (TIMESTAMP), required, records when the test was performed.
     399
     400----
     401'''`confirmed_group`'''
     402
     403The `confirmed_group` relationship connects `BloodUnit` and `BloodGroup`. It records the blood group confirmed for a collected blood unit after the appropriate testing and verification procedures. It is modeled as a one-to-many relationship because multiple blood units can have the same confirmed blood group, while each blood unit is assigned one blood group.
     404
     405'''Cardinality:''' `BloodGroup` (1) : `BloodUnit` (N).
     406
     407'''Relationship attributes:''' None.
     408
     409----
     410'''`separated_into`'''
     411
     412The `separated_into` relationship connects `BloodUnit` and `Component`. It represents the process of separating a collected blood unit into individual blood components. It is the identifying relationship of the weak entity `Component`, which is identified by its blood unit together with its own `component_no`. It is modeled as a one-to-many relationship because one blood unit can produce multiple components, while each component originates from one blood unit.
     413
     414'''Cardinality:''' `BloodUnit` (1) : `Component` (N).
     415
     416'''Relationship attributes:''' None.
     417
     418----
     419'''`of_type`'''
     420
     421The `of_type` relationship connects `Component` and `ComponentType`. It classifies each individual blood component according to its corresponding component type. It is modeled as a one-to-many relationship because multiple components can belong to the same component type, while each component has one defined type.
     422
     423'''Cardinality:''' `ComponentType` (1) : `Component` (N).
     424
     425'''Relationship attributes:''' None.
     426
     427----
     428'''`discards`'''
     429
     430The `discards` relationship connects `LabTechnician` and `Component`. It records which laboratory technician is responsible for discarding a blood component. It is modeled as a one-to-many relationship because one laboratory technician can discard multiple components, while each discarded component is associated with one technician.
     431
     432'''Cardinality:''' `LabTechnician` (1) : `Component` (N).
     433
     434'''Relationship attributes:'''
     435 * `discarded_at` – Date and time (TIMESTAMP), required, records when the component was discarded.
     436 * `reason` – Text (TEXT), required, describes the reason for discarding the component.
     437
     438----
     439'''`compatible_with`'''
     440
     441The `compatible_with` relationship connects `BloodGroup` with itself and `ComponentType`. It represents blood group compatibility rules based on the donor's blood group, the recipient's blood group, and the type of blood component. The `BloodGroup` entity participates twice in this relationship, with the distinct roles of `donor` and `recipient`. It is modeled as a ternary recursive relationship because compatibility depends on the combination of these three elements rather than on blood groups alone.
     442
     443'''Cardinality:''' `BloodGroup` as `donor` (M) : `BloodGroup` as `recipient` (N) : `ComponentType` (P).
     444
     445'''Relationship attributes:''' None.
     446
     447----
     448'''`sends`'''
     449
     450The `sends` relationship connects `Hospital` and `BloodRequest`. It represents the submission of blood requests by hospitals to the transfusion center. It is modeled as a one-to-many relationship because one hospital can submit multiple blood requests, while each blood request is submitted by one hospital.
     451
     452'''Cardinality:''' `Hospital` (1) : `BloodRequest` (N).
     453
     454'''Relationship attributes:''' None.
     455
     456----
     457'''`for_patient`'''
     458
     459The `for_patient` relationship connects `BloodRequest` and `Patient`. It identifies the patient for whom a particular blood request is submitted. It is modeled as a one-to-many relationship because one patient can have multiple blood requests over time, while each request is intended for at most one patient.
     460
     461'''Cardinality:''' `Patient` (1) : `BloodRequest` (N).
     462
     463'''Relationship attributes:''' None.
     464
     465----
     466'''`requests`'''
     467
     468The `requests` relationship connects `BloodRequest`, `BloodGroup`, and `ComponentType`. It represents the specific blood components requested by a hospital, taking into account the required blood group and component type. It is modeled as a ternary relationship because the requested quantity depends on the combination of a particular blood request, blood group, and component type. This allows a single request to include multiple component types and blood groups, each with its own requested quantity.
     469
     470'''Cardinality:''' `BloodRequest` (M) : `ComponentType` (N) : `BloodGroup` (P).
     471
     472'''Relationship attributes:'''
     473 * `quantity` – Numeric (INTEGER), required, represents the number of units requested for the specified blood group and component type; must be a positive integer.
     474
     475----
     476'''`treated_at`'''
     477
     478The `treated_at` relationship connects `Hospital` and `Patient`. It identifies the hospital at which a patient receives medical treatment. It is modeled as a one-to-many relationship because one hospital can treat multiple patients, while each patient is associated with one hospital in the current model.
     479
     480'''Cardinality:''' `Hospital` (1) : `Patient` (N).
     481
     482'''Relationship attributes:''' None.
     483
     484----
     485'''`patient_group`'''
     486
     487The `patient_group` relationship connects `Patient` and `BloodGroup`. It associates each patient with their recorded blood group. It is modeled as a one-to-many relationship because multiple patients can share the same blood group, while each patient has at most one recorded blood group.
     488
     489'''Cardinality:''' `BloodGroup` (1) : `Patient` (N).
     490
     491'''Relationship attributes:''' None.
     492
     493----
     494'''`allocated_to`'''
     495
     496The `allocated_to` relationship connects `BloodRequest` and `Component`. It records the allocation of available blood components to a particular hospital blood request. It is modeled as a one-to-many relationship because one blood request can have multiple allocated components, while each component is associated with at most one blood request.
     497
     498'''Cardinality:''' `BloodRequest` (1) : `Component` (N).
     499
     500'''Relationship attributes:'''
     501 * `allocated_at` – Date and time (TIMESTAMP), required, records when the component was allocated to the request.
     502
     503----
     504'''`crossmatched`'''
     505
     506The `crossmatched` relationship connects `Component` and `Patient`. It represents the compatibility testing performed between a blood component and a patient before transfusion. It is modeled as a many-to-many relationship because a component may be crossmatched against multiple patients, while a patient may undergo crossmatching with multiple components.
     507
     508'''Cardinality:''' `Component` (M) : `Patient` (N).
     509
     510'''Relationship attributes:'''
     511 * `result` – Text (VARCHAR), required, stores the crossmatching result, one of: `compatible`, `incompatible`.
     512 * `tested_at` – Date and time (TIMESTAMP), required, records when the crossmatching test was performed.
     513
     514----
     515'''`receives`'''
     516
     517The `receives` relationship connects `Patient` and `Transfusion`. It represents the administration of a blood transfusion to a patient. It is modeled as a one-to-many relationship because one patient can receive multiple transfusions over time, while each transfusion belongs to one patient.
     518
     519'''Cardinality:''' `Patient` (1) : `Transfusion` (N).
     520
     521'''Relationship attributes:''' None.
     522
     523----
     524'''`uses`'''
     525
     526The `uses` relationship connects `Component` and `Transfusion`. It identifies the blood component used during a particular transfusion. It is modeled as a one-to-one relationship because each transfusion uses exactly one component, and a component can be used in at most one transfusion.
     527
     528'''Cardinality:''' `Component` (1) : `Transfusion` (1).
     529
     530'''Relationship attributes:''' None.
     531
     532----
     533
     534== Entity-Relationship Model History ==
     535
     536 * [attachment:ERModel_v01.png v01] – Initial version of the model.