| 34 | | J1 ← P ⨝{P.id_user = U.id_user} U |
| 35 | | |
| 36 | | Ј2 ← Ј1 ⟕{P.id_user = C.id_patient} C |
| 37 | | |
| 38 | | Ј3 ← Ј2 ⟕{C.id_consultation = TH.id_consultation} TH |
| 39 | | |
| 40 | | Ј4 ← Ј3 ⨝{P.id_user = D.id_patient} D |
| | 34 | J1 ← P ⨝,,P.id_user = U.id_user,, U |
| | 35 | |
| | 36 | Ј2 ← Ј1 ⟕,,P.id_user = C.id_patient,, C |
| | 37 | |
| | 38 | Ј3 ← Ј2 ⟕,,C.id_consultation = TH.id_consultation,, TH |
| | 39 | |
| | 40 | Ј4 ← Ј3 ⨝,,P.id_user = D.id_patient,, D |
| 104 | | F1 ← π{id_user, id_consultation, price, date_of_payment, YEAR(date) -> Year, CONCAT(name, ' ', surname) -> Therapist_Name} (J2) |
| | 104 | F1 ← π,,id_user, id_consultation, price, date_of_payment, YEAR(date) -> Year, CONCAT(name, ' ', surname) -> Therapist_Name,, (J2) |
| 108 | | G ← {Year, id_user, Therapist_Name} σ |
| 109 | | COUNT(id_consultation) -> Total_Consultations, |
| | 108 | G ← ,,Year, id_user, Therapist_Name,, γ |
| | 109 | ,,COUNT(id_consultation) -> Total_Consultations, |
| 116 | | P ← π{Year, id_user, Therapist_Name, Total_Consultations, Completed_Consultations, Avg_Consultation_Price, (Completed_Consultations/ Total_Consultations) * 100 -> Completion_Rate_Percentage} (G) |
| | 116 | P ← π,,Year, id_user, Therapist_Name, Total_Consultations, Completed_Consultations, Avg_Consultation_Price, (Completed_Consultations/ Total_Consultations) * 100 -> Completion_Rate_Percentage,, (G) |
| 192 | | J{lp} ← C ⨝{C.id_therapist = T.id_user} T ⨝{T.id_user = U.id_user} U |
| 193 | | |
| 194 | | LP ← σ{count_c >= 10} ({id_patient, id_therapist, name, surname} σ{COUNT(id_consultation) -> count_c} (J{lp})) |
| | 192 | J,,lp,,← C ⨝,,C.id_therapist = T.id_user,, T ⨝,,T.id_user = U.id_user,, U |
| | 193 | |
| | 194 | LP ← σ,,count_c >= 10,, ({id_patient, id_therapist, name, surname} γ,,COUNT(id_consultation) -> count_c,, (J,,lp,,)) |
| 198 | | J{bs} ← B ⟕{B.id_blog = COM.id_blog} COM |
| 199 | | |
| 200 | | F{bs} ← π{id_patient, id_blog, id_comment, YEAR(date_of_post) -> post_year} (J{bs}) |
| 201 | | |
| 202 | | BS ← {id_patient, post_year} σCOUNT(DISTINCT {id_blog} -> blogs_count, COUNT(id_comment) -> comments_count} (F{bs}) |
| | 198 | J,,bs,, ← B ⟕,,B.id_blog = COM.id_blog,, COM |
| | 199 | |
| | 200 | F,,bs,, ← π,,id_patient, id_blog, id_comment, YEAR(date_of_post) -> post_year,, (J{bs}) |
| | 201 | |
| | 202 | BS ← ,,id_patient, post_year,, γ,,COUNT(DISTINCT,,id_blog,, -> blogs_count, COUNT(id_comment) -> comments_count,, (F{bs}) |
| 206 | | J{final} ← LP ⨝{LP.id_patient = BS.id_patient} BS |
| 207 | | |
| 208 | | F{final} ← π{post_year, CONCAT(name, ' ', surname) -> Therapist, blogs_count, comments_count} (J{final}) |
| 209 | | |
| 210 | | G ← {post_year, Therapist} σ |
| 211 | | SUM(blogs_count) -> Total_Blogs, |
| | 206 | J,,final,, ← LP ⨝,,LP.id_patient = BS.id_patient,, BS |
| | 207 | |
| | 208 | F,,final,, ← π,,post_year, CONCAT(name, ' ', surname) -> Therapist, blogs_count, comments_count,, (J,,final,,) |
| | 209 | |
| | 210 | G ← ,,post_year, Therapist,, γ |
| | 211 | ,,SUM(blogs_count) -> Total_Blogs, |
| 300 | | F{bm} ← π{id_blog, id_patient, YEAR(date_of_post) -> year, MONTH(date_of_post) -> month} (B) |
| 301 | | |
| 302 | | BM ← {year, month} σCOUNT(id_blog) -> total_blogs, COUNT(DISTINCT {id_patient}) -> active_bloggers} (F{bm}) |
| | 300 | F,,bm,, ← π,,id_blog, id_patient, YEAR(date_of_post) -> year, MONTH(date_of_post) -> month,, (B) |
| | 301 | |
| | 302 | BM ← ,,year, month,, γ,,COUNT(id_blog) -> total_blogs, COUNT(DISTINCT,,id_patient,,) -> active_bloggers,, (F{bm}) |
| 306 | | F{dm} ← π{id_diary, id_patient, daily_rating, YEAR(date) -> year, MONTH(date) -> month} (D) |
| 307 | | |
| 308 | | DM ← {year, month} σ{COUNT(id_diary) -> total_diaries, COUNT(DISTINCT id\_patient) -> active_diarists, AVG(daily_rating) -> avg_monthly_mood} (F{dm}) |
| | 306 | F,,dm} ← π,,id_diary, id_patient, daily_rating, YEAR(date) -> year, MONTH(date) -> month,, (D) |
| | 307 | |
| | 308 | DM ← ,,year, month,, σ,,COUNT(id_diary) -> total_diaries, COUNT(DISTINCT id\_patient) -> active_diarists, AVG(daily_rating) -> avg_monthly_mood,, (F,,dm,,) |
| 312 | | MS ← BM ⟗{BM.year = DM.year ∧ BM.month = DM.month} DM |
| 313 | | |
| 314 | | MS{final} ← π{COALESCE(BM.year, DM.year) -> year, COALESCE(BM.month, DM.month) -> month, ..., avg_monthly_mood} (MS) |
| | 312 | MS ← BM ⟗,,BM.year = DM.year ∧ BM.month = DM.month,, DM |
| | 313 | |
| | 314 | MS,,final,, ← π,,COALESCE(BM.year, DM.year) -> year, COALESCE(BM.month, DM.month) -> month, ..., avg_monthly_mood,, (MS) |
| 319 | | π{year, month, total_blogs, total_diaries, avg_monthly_mood, (total_blogs / active_bloggers) -> BlogsPerUser, (total_diaries / active_diarists) -> DiariesPerUser} (MS{final}) |
| 320 | | |
| 321 | | P{ext} ← |
| 322 | | π{*, CASE_WHEN}(...) -> BehaviourType, (total_blogs / (total_blogs + total_diaries)) * 100 -> PublicityRate} (P) |
| | 319 | π,,year, month, total_blogs, total_diaries, avg_monthly_mood, (total_blogs / active_bloggers) -> BlogsPerUser, (total_diaries / active_diarists) -> DiariesPerUser,, (MS,,final,,) |
| | 320 | |
| | 321 | P,,ext,, ← |
| | 322 | π,,*, CASE_WHEN(...) -> BehaviourType, (total_blogs / (total_blogs + total_diaries)) * 100 -> PublicityRate,, (P) |