Changes between Initial Version and Version 1 of Normalization


Ignore:
Timestamp:
01/21/26 22:07:34 (3 weeks ago)
Author:
233144
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Normalization

    v1 v1  
     1= Normalization
     2
     3Our database has the following identificators: user_id, component_id, build_id, review_id and suggestion_id.\\
     4Some of the relations have composite primary keys, such as:\\
     5(build_id, component_id) - build_component\\
     6(build_id, user_id) - rating_build\\
     7(build_id, user_id) - favorite_build\\
     8The component subtypes like CPU, GPU, Motherboard etc. do not have separate identificators, because they use component_id as both primary and foreign key referencing the **components** table.
     9
     10== Functional Dependencies
     11
     12user_id → username, password, email\\
     13user_id → / (admins is a subtype of user with no additional attributes)\\
     14
     15component_id → name, brand, price, type, img_url\\
     16
     17component_id → socket, cores, threads, base_clock, boost_clock, tdp                 (cpu)\\
     18component_id → vram, tdp, base_clock, boost_clock, chipset, length                (gpu)\\
     19component_id → memory_type, speed, capacity, modules                              (memory)\\
     20component_id → storage_type, capacity, form_factor                                (storage)\\
     21component_id → psu_type, wattage, form_factor                                     (power_supply)\\
     22component_id → socket, chipset, form_factor, ram_type, num_ram_slots, max_ram_capacity, pci_express_slots                                (motherboard)\\
     23component_id → cooler_max_height, gpu_max_length                                   (pc_case)\\
     24component_id → cooler_type, height, max_tdp_supported                               (cooler)\\
     25component_id → num_slots, interface                                                (memory_card)\\
     26component_id → form_factor, type, interface, write_speed, read_speed               (optical_drive)\\
     27component_id → sample_rate, bit_depth, chipset, interface, channel                 (sound_carad)\\
     28component_id → length_cm, type                                                     (cable)\\
     29component_id → wifi_version, interface, num_antennas                               (network_adapter)\\
     30component_id → num_ports, speed, interface                                        (network_card)\\
     31
     32build_id → user_id, name, created_at, description, total_price, is_approved\\
     33build_id, component_id → / (build_component)\\
     34
     35build_id, user_id → / (favorite_build)\\
     36build_id, user_id → value (rating_build)\\
     37
     38review_id → build_id, user_id, content, created_at\\
     39
     40suggestion_id → user_id, admin_id, link, description, admin_comment, status, component_type\\
     41
     42== Universal Relation (R)
     43
     44R = {
     45user_id, username, password, email,
     46component_id, name, brand, price, type, img_url,
     47cpu_socket, cpu_cores, cpu_threads, cpu_base_clock, cpu_boost_clock, cpu_tdp,
     48gpu_vram, gpu_tdp, gpu_base_clock, gpu_boost_clock, gpu_chipset, gpu_length,
     49memory_type, memory_speed, memory_capacity, memory_modules,
     50storage_type, storage_capacity, storage_form_factor,
     51psu_type, psu_wattage, psu_form_factor,
     52motherboard_socket, motherboard_chipset, motherboard_form_factor,
     53ram_type, num_ram_slots, max_ram_capacity, pci_express_slots,
     54case_cooler_max_height, case_gpu_max_length,
     55cooler_type, cooler_height, max_tdp_supported,
     56build_id, build_name, created_at, description, total_price, is_approved,
     57rating_value,
     58review_id, review_content, review_created_at,
     59suggestion_id, link, admin_comment, status, component_type
     60}
     61
     62Left (determinants):\\
     63user_id\\
     64component_id\\
     65build_id\\
     66review_id\\
     67suggestion_id\\
     68
     69Right (descriptive attributes), attributes with similar names are prefixed (cpu_, gpu_, build_, etc.):\\
     70username, password, email,\\
     71name, brand, price, type, img_url,\\
     72cpu_*, gpu_*, memory_*, storage_*, psu_*, motherboard_*, case_*, cooler_*,\\
     73build_name, created_at, description, total_price, is_approved,\\
     74rating_value,\\
     75review_content, review_created_at,\\
     76link, admin_comment, status, component_type\\
     77
     78Left and right:\\
     79user_id\\
     80component_id\\
     81build_id\\
     82
     83== Attribute Closures
     84
     85user_id+ = { user_id, username, password, email }
     86
     87component_id+ = { component_id, name, brand, price, type, img_url,
     88cpu_socket, cpu_cores, cpu_threads, cpu_base_clock, cpu_boost_clock, cpu_tdp,
     89gpu_vram, gpu_tdp, gpu_base_clock, gpu_boost_clock, gpu_chipset, gpu_length,
     90memory_type, memory_speed, memory_capacity, memory_modules,
     91storage_type, storage_capacity, storage_form_factor,
     92psu_type, psu_wattage, psu_form_factor,
     93motherboard_socket, motherboard_chipset, motherboard_form_factor,
     94ram_type, num_ram_slots, max_ram_capacity, pci_express_slots,
     95case_cooler_max_height, case_gpu_max_length,
     96cooler_type, cooler_height, max_tdp_supported,
     97num_slots, interface, form_factor, type, write_speed, read_speed,
     98sample_rate, bit_depth, chipset, interface, channel,
     99length_cm, type,
     100wifi_version, interface, num_antennas,
     101num_ports, speed, interface }
     102
     103build_id+ = { build_id, user_id, name, created_at, description, total_price, is_approved }
     104
     105(build_id, component_id)+ = { build_id, component_id }   -- Build_Component
     106
     107(build_id, user_id)+ = { build_id, user_id, rating_value }   -- RatingBuild
     108
     109review_id+ = { review_id, build_id, user_id, content, created_at }
     110
     111suggestion_id+ = { suggestion_id, user_id, admin_id, link, description, admin_comment, status, component_type }
     112
     113
     114The union of\\
     115{ user_id, component_id, build_id, review_id, suggestion_id }+\\
     116covers all attributes of R, so 1NF (First Normal Form) is satisfied. Now in this (lets call it) "super-table", if we consider **component_id** + other IDs as a composite key for the super-table, attributes like **cpu_socket** depend on **component_id** only, not on other IDs like **build_id** or **user_id**. This is a partial dependency, which means that 2NF is not satisfied.
     117
     118== 2NF Decomposition
     119
     120**First we will identify the partial dependencies:**\\
     121
     122user_id → username, email, password, is_admin\\
     123
     124component_id → name, brand, price, type, img_url, cpu_socket, cpu_cores, cpu_threads, cpu_base_clock, cpu_boost_clock, cpu_tdp,
     125gpu_vram, gpu_tdp, gpu_base_clock, gpu_boost_clock, gpu_chipset, gpu_length,
     126memory_type, memory_speed, memory_capacity, memory_modules,
     127storage_type, storage_capacity, storage_form_factor,
     128psu_type, psu_wattage, psu_form_factor,
     129motherboard_socket, motherboard_chipset, motherboard_form_factor,
     130ram_type, num_ram_slots, max_ram_capacity, pci_express_slots,
     131case_cooler_max_height, case_gpu_max_length,
     132cooler_type, cooler_height, max_tdp_supported
     133
     134build_id → user_id, name, created_at, description, total_price, is_approved
     135
     136(build_id, user_id) → rating_value
     137
     138review_id → review_build_id (FK build_id), review_user_id (FK user_id), review_content
     139
     140suggestion_id → suggestion_user_id, suggestion_admin_id, suggestion_link, suggestion_admin_comment, suggestion_description, suggestion_status, suggestion_component_type
     141
     142(build_id, component_id) → /
     143
     144(build_id, user_id) → /
     145
     146**Then we will extract the proper relations:**\\
     147
     148users { user_id, username, email, password } - BCNF
     149admins { user_id } → FK to users - BCNF
     150
     151components { component_id, name, brand, price, type, img_url } - BCNF
     152
     153cpu { component_id, socket, cores, threads, base_clock, boost_clock, tdp } → FK to components - BCNF\\
     154gpu { component_id, vram, tdp, base_clock, boost_clock, chipset, length } → FK to components - BCNF\\
     155memory { component_id, type, speed, capacity, modules } → FK to components - BCNF\\
     156storage { component_id, type, capacity, form_factor } → FK to components - BCNF\\
     157power_supply { component_id, type, wattage, form_factor } → FK to components - BCNF\\
     158motherboard{ component_id, socket, chipset, form_factor, ram_type, num_ram_slots, max_ram_capacity, pci_express_slots } → FK to components - BCNF\\
     159pc_case { component_id, cooler_max_height, gpu_max_length } → FK to components - BCNF\\
     160case_storage_form_factors { case_id, form_factor, num_slots } → FK to pc_case - BCNF\\
     161case_ps_form_factors { case_id, form_factor } → FK to pc_case - BCNF\\
     162case_mobo_form_factors { case_id, form_factor } → FK to pc_case - BCNF\\
     163cooler { component_id, type, height, max_tdp_supported } → FK to components - BCNF\\
     164cooler_cpu_sockets { cooler_id, socket } → FK to cooler - BCNF\\
     165memory_card { component_id, num_slots, interface } → FK to components - BCNF\\
     166optical_drive { component_id, form_factor, type, interface, write_speed, read_speed } → FK to components - BCNF\\
     167sound_card { component_id, sample_rate, bit_depth, chipset, interface, channel } → FK to components - BCNF\\
     168cables { component_id, length_cm, type } → FK to components - BCNF\\
     169network_adapter { component_id, wifi_version, interface, num_antennas } → FK to components - BCNF\\
     170network_card { component_id, num_ports, speed, interface } → FK to components - BCNF\\
     171
     172build { build_id, build_user_id, build_name, created_at, description, total_price, is_approved } → FK to users - BCNF\\
     173build_component { build_id, component_id } → FK to build and components - BCNF\\
     174
     175favorite_build { build_id, user_id } → FK to build and users - BCNF\\
     176rating_build { build_id, user_id, value } → FK to build and users - BCNF\\
     177review { review_id, build_id, user_id, content, created_at } → FK to build and users - BCNF\\
     178
     179suggestions { id, user_id, admin_id, link, admin_comment, description, status, component_type } → FK to users/admins - BCNF\\
     180
     181== Check 3NF and BCNF
     182
     183We can see that all foreign keys point to primary keys, so no transitive dependencies can be detected here. All component subtypes are in separate tables which removes the partial dependencies from before. We also separated the user roles, and in the relations all non-key attributes fully depend on their primary key.
     184
     1853NF/BCNF is satisfied.