Changes between Version 5 and Version 6 of Normalization


Ignore:
Timestamp:
08/27/25 13:01:33 (6 days ago)
Author:
221007
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Normalization

    v5 v6  
    186186Втората нормална форма е задоволена ако е задоволена првата нормална форма и дополнително ако нема парцијални функционални зависности. Подобро објаснето, секој атрибут кој не е примарен, треба целосно да биде функционално зависен од примарниот клуч.
    187187
    188 Во оваа фаза, мегарелацијата R е декомпонирана во неколку логички релации, така што:
    189 * Секој атрибут е целосно функционално зависен од еден атомски примарен клуч
    190 * Нема парцијални функционални зависности
    191 * Секоја релација ја задоволува Втората Нормална Форма (2NF)
     188Релациите кои се добиваат ги задоволуваат следните 2 услови, за да бидат во 2NF:
     189* Секој атрибут е целосно функционално зависен од целиот (композитен) клуч кога има истиот постои (доколку е атомски, 2NF е веќе задоволена).
    192190
    193191За да ги отстраниме парцијалните зависности потребно е да ги оделиме атрибутите во релации во кои целосно ќе зависат од нивниот клуч:
    194192
    195 export_id -> session_id, export_format, file_name, filter_summary, export_date
    196 
    197 punishment_id -> report_id, value_unit, punishment_type, fine_to_pay, release_date
    198 
    199 log_id -> profile_id, change_description, changed_at
    200 
    201 r_d_id -> diagnosis_id, report_id, added_on
    202 
    203 report_id -> report_type, report_created_at, summary, person_id, location, resolved, crime_type_id, descriptive_punishment, academic_field, institution_id, description_of_report, start_date, end_date, job_role, income_per_month, next_control_date, doctor_id
     193R1: export_id PK, session_id , export_format, file_name, filter_summary, export_date
     194
     195R2: log_id PK, profile_id, change_description, changed_at
     196
     197R3: punishment_id PK, report_id, value_unit, punishment_type, fine_to_pay, release_date
     198
     199R4: r_d_id PK, diagnosis_id, report_id, added_on
     200
     201R5: report_id PK, report_type, report_created_at, summary, person_id, location, resolved, crime_type_id, descriptive_punishment, academic_field, institution_id, description_of_report, start_date, end_date, job_role, income_per_month, next_control_date, doctor_id – е во BCNF, но ќе резултира со многу null полиња во еден запис, по што може да употребиме „''Supertype-Subtype Specialization''“
     202
     203Бидејќи report_id е клуч кај сите, и тие би биле соодветно диференцирани по тип земајќи го во предвид report_type, ќе може да се издвои еден Supertype и од него да произлегуваат соодветно неколку Subtypes. За правилно да го направиме ова, ќе ги гледаме функционалните зависности:
     204
     205* R5.1: report_id PK, report_type, report_created_at, summary, person_id
     206* R5.1.1: report_id PK, location, resolved, crime_type_id, descriptive_punishment
     207* R5.1.2: report_id PK, academic_field, institution_id, description_of_report
     208* R5.1.3: report_id PK, start_date, end_date, job_role, income_per_month
     209* R5.1.4: report_id PK, next_control_date, doctor_id
    204210
    205211=== BCNF комбинирано со 3NF
    206212
    207 R1: export_id PK, session_id , export_format, file_name, filter_summary, export_date – во BCNF
    208 
    209 R2: log_id PK, profile_id, change_description, changed_at – во BCNF
    210 
    211 R3: punishment_id PK, report_id, value_unit, punishment_type, fine_to_pay, release_date – во BCNF
    212 
    213 R4: r_d_id PK, diagnosis_id, report_id, added_on – во BCNF
    214 
    215 R5: report_id PK, report_type, report_created_at, summary, person_id, location, resolved, crime_type_id, descriptive_punishment, academic_field, institution_id, description_of_report, start_date, end_date, job_role, income_per_month, next_control_date, doctor_id – е во BCNF, но ќе резултира со многу null полиња во еден запис, по што може да употребиме „''Supertype-Subtype Specialization''“
    216 
    217 Бидејќи report_id е клуч кај сите, и тие би биле соодветно диференцирани по тип земајќи го во предвид report_type, ќе може да се издвои еден Supertype и од него да произлегуваат соодветно неколку Subtypes. За правилно да го направиме ова, ќе ги гледаме функционалните зависности:
    218 
    219 * R5.1: report_id PK, report_type, report_created_at, summary, person_id – во BCNF
    220 * R5.1.1: report_id PK, location, resolved, crime_type_id, descriptive_punishment – во BCNF
    221 * R5.1.2: report_id PK, academic_field, institution_id, description_of_report – во BCNF
    222 * R5.1.3: report_id PK, start_date, end_date, job_role, income_per_month – во BCNF
    223 * R5.1.4: report_id PK, next_control_date, doctor_id – во BCNF
    224 
    225 Атрибутите од подтип се условни од report_type својството, затоа ги логички подобро би фигурирале во погрануларни релации. Секоја од овие продолжува поединечно да го задоволува својството за BCNF, а со тоа и 3NF.
    226 
    227 R6: остатокот од атрибути = { report_id, export_id, log_id, punishment_id, r_d_id, user_id, user_name, user_surname, email, password_hash, is_user_active, user_created_at, role_id, username, profile_created_at, role_name, role_descrioption, filter_description, searched_at, embg, name, surname, gender, date_of_birth, is_alive, date_of_death, address_of_living, contact_phone, institution_name, institution_address, city, type, year_established, label, severity_level, doctor_name, doctor_surname, specialization, years_of_experience, is_active, short_description, therapy, is_chronic, severity } – во ниту еден случај не е во BCNF
     213Пред да продолжиме со било што друго, потребно е соодветно да разгледаме што е добиено во претходните нормализирани форми.
     214Се добиваат R1, R2, R3, R4, R5 ---> R5.1, R5.1.1, R5.1.2, R5.1.3, R5.1.4. Според условите кои ги поставува BCNF, овие релации ја задоволуваат бојс-кодовата нормална форма, а тоа би значело дека исто времено ја задоволуваат и 3NF.
     215
     216Останѕува уште:
     217R6: rest_of_the_attributes_relation = { report_id, export_id, log_id, punishment_id, r_d_id, user_id, user_name, user_surname, email, password_hash, is_user_active, user_created_at, role_id, username, profile_created_at, role_name, role_descrioption, filter_description, searched_at, embg, name, surname, gender, date_of_birth, is_alive, date_of_death, address_of_living, contact_phone, institution_name, institution_address, city, type, year_established, label, severity_level, doctor_name, doctor_surname, specialization, years_of_experience, is_active, short_description, therapy, is_chronic, severity } – во ниту еден случај не е во BCNF
    228218
    229219Гарантиравме дека role_name е уникатно, па затоа може да издвоиме релација