spring mvc - How to remove records simultaneously? -


case: in package have class performs activirt patients & doctors

  • patient specifict operations( post, get, put, delete) done patient controller,

  • doctor specifict operations( post, get, put, delete ) done doctor controller

there are:

  • 4 doctors: a, b, c , d;
  • 50 patients - 1 of them name z
  • one doctor have multiple patients
  • one patient can consult multiple doctors

patient z consults doctors a, b & d.

question: how to, upon deletion of patient, remove each of doctors attends, , upon deletion of doctor, remove patients attended him?

if understand use case correctly , want

doctor attended patients x, y, z…
doctor b attended patients x, y, z…
doctor c attended patients x, y, k… ( doctor c did not attended patient z).
doctor d attended patients x, y, z…

now looking in list of patients attended doctor a, , deleted patient z list. , patient z should deleted list of doctor b , d. want model data cassandra database.

we need remember goals while modelling cassandra schema.

first goal– know query data.
second goal – try distribute data across cluster.
third goal – minimise number partition reads.

our queries -
1 – patients attended doctor (b,c,d).
2 – delete patient history (from list).

let’s give try -

create table visits_by_doctor(  doctor_name  text ,  patient_name  text ,  .  .  .  other columns    primary key (doctor_name, patient_name    ) ) 

this satisfy our 2 goals. first goal, in 1 query can list of patients attended doctor a.
select * visits_by_doctor doctor_name = a;
delete visits_by_doctor patient_name = z;

second goal , minimize number of partition reads can data based on partition key “doctor_name”. design not satisfy third goal, spread data across cluster. let’s improve it.

create table visits_by_doctor( doctor_name  text , patient_name  text , visit_date bigint, . other columns   primary key ((doctor_name, patient_name), visit_date    ) ) clustering order (visit_date    desc). 

this satisfy “spread data across cluster” goal. can used history based on visiting date.


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -