Changes between Initial Version and Version 1 of BuildBoardF6


Ignore:
Timestamp:
07/07/25 23:02:20 (6 days ago)
Author:
221071
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildBoardF6

    v1 v1  
     1== Нормализација
     2
     3За табелите од нашата база на податоци, со цел разликување на самите id за секој ентитет, ќе ги преименуваме id атрибутите во <име_на_релација>_id. Со тоа добиваме:
     4user_id, property_id, property_type_id, property_image_id, unit_id, listing_id, lease_id, payment_id, payment_method_id, tenant_profile_id, landlord_profile_id, service_request_id, service_category_id, maintenance_log_id, inspection_id, document_id, address_id, message_id, unit_image_id
     5
     6**user_id** -> first_name, last_name, email, password_hash, date_of_birth, rating, address_id, bio [[br]]
     7**property_id** -> property_title, property_description, created_at, user_id, property_type_id, address_id [[br]]
     8**property_type_id** -> property_type_name [[br]]
     9**property_image_id** -> property_image, property_id [[br]]
     10**unit_id** -> unit_number, floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount, property_id [[br]]
     11**listing_id** -> listing_title, available_from, available_to, listing_status, listing_description, unit_id [[br]]
     12**lease_id** -> start_date, end_date, lease_rent_amount, deposit_amount, listing_id, tenant_profile_id, landlord_profile_id [[br]]
     13**payment_id** -> amount, payment_status, payment_date, lease_id, payment_method_id [[br]]
     14**payment_method_id** -> payment_method_name [[br]]
     15**landlord_profile_id** -> managed_properties_count, is_agent [[br]]
     16**service_request_id** -> service_description, request_date, service_status, lease_id, service_category_id [[br]]
     17**service_category_id** -> service_category_name [[br]]
     18**maintenance_log_id** -> maintenance_description, maintenance_date, service_request_id [[br]]
     19**inspection_id** -> inspection_date, notes, lease_id, landlord_profile_id [[br]]
     20**document_id** -> file_type, file_url, uploaded_at, user_id, lease_id [[br]]
     21**address_id** -> street, municipality, city, number, country [[br]]
     22**message_id** -> sent_at, content, user_id, user_id, lease_id [[br]]
     23**unit_image_id** -> unit_image, unit_id [[br]]
     24**tenant_profile_id** -> / [[br]]
     25**listing_id, tenant_profile_id** -> / [[br]]
     26
     27user_id се спомнува два пати кај ФЗ со message_id од левата страна поради тоа што имаме испраќач и примач на порака.
     28
     29**R** = { user_id, first_name, last_name, email, password_hash, date_of_birth, rating, address_id, bio, tenant_profile_id, property_id, property_title, property_description, created_at, property_type_id, property_type_name, property_image_id, property_image, unit_id, unit_number, floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount, unit_image_id, unit_image, listing_id, listing_title, available_from, available_to, listing_status, listing_description, lease_id, start_date, end_date, lease_rent_amount, deposit_amount, landlord_profile_id, managed_properties_count, is_agent, payment_id, amount, payment_status, payment_date, payment_method_id, payment_method_name, service_request_id, service_description, request_date, service_status, service_category_id, service_category_name, maintenance_log_id, maintenance_description, maintenance_date, inspection_id, inspection_date, notes, document_id, file_type, file_url, uploaded_at, street, municipality, city, number, country, message_id, sent_at, content }
     30
     31Лево
     32property_image_id
     33payment_id
     34maintenance_log_id
     35inspection_id
     36document_id
     37message_id
     38unit_image_id
     39tenant_profile_id
     40
     41Лево и десно
     42user_id
     43property_id
     44property_type_id
     45unit_id
     46listing_id
     47lease_id
     48landlord_profile_id
     49payment_method_id
     50service_request_id
     51service_category_id
     52address_id
     53
     54
     55
     56Десно
     57first_name, last_name, email, password_hash, date_of_birth, rating, bio, property_title, property_description, created_at, property_type_name, property_image, unit_number, floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount, listing_title, available_from, available_to, listing_status, listing_description, start_date, end_date, lease_rent_amount, deposit_amount, amount, payment_status, payment_date, payment_method_name, managed_properties_count, is_agent, service_description, request_date, service_status, service_category_name, maintenance_description, maintenance_date, inspection_date, notes, file_type, file_url, uploaded_at, street, municipality, city, number, country, sent_at, content, unit_image
     58
     59
     60=== Покривачи за 8-те атрибути:
     611.** property_image_id+** = {property_image_id, property_image, property_id, property_title, property_description, created_at, user_id, property_type_id, address_id, property_type_name, street, municipality, city, number, country, first_name, last_name, email, password_hash, date_of_birth, rating, bio} **-Не ги содржи сите атрибути.**
     62
     632.** payment_id+** = {payment_id, amount, payment_status, payment_date, lease_id,payment_method_id, payment_method_name, start_date, end_date, lease_rent_amount,
     64deposit_amount, listing_id, tenant_profile_id, landlord_profile_id, listing_title, available_from,
     65available_tod, listing_status, listing_description, unit_id, unit_number, floor, bedrooms,
     66bathrooms, area_sq_m, unit_rent_amount, property_id, managed_properties_count, is_agent,
     67user_id, property_title, property_description, created_at, property_type_id, address_id,
     68property_type_name, street, municipality, city, number, country, first_name, last_name, email,
     69password_hash, date_of_birth, rating, bio} **-Не ги содржи сите атрибути.**
     70
     713.** maintenance_log_id+** = {maintenance_log_id, maintenance_description,maintenance_date,service_request_id, service_description, request_date, service_status, lease_id,
     72service_category_id, service_category_name, start_date, end_date, lease_rent_amount,
     73deposit_amount, listing_id, tenant_profile_id, landlord_profile_id, managed_properties_count,
     74is_agent, user_id, first_name, last_name, email, password_hash, date_of_birth, rating,
     75address_id, bio, street, municipality, city, number, country, listing_title, available_from,
     76available_to, listing_status, listing_description, unit_id, unit_number, floor, bedrooms,
     77bathrooms, area_sq_m, unit_rent_amount, property_id, property_title, property_description,
     78created_at, property_type_id, property_type_name} **-Не ги содржи сите атрибути.**
     79
     804.** inspection_id+** = {inspection_id, inspection_date, notes, lease_id, landlord_profile_id,
     81managed_properties_count, is_agent, start_date, end_date, lease_rent_amount,
     82deposit_amount, listing_id, tenant_profile_id, user_id, first_name, last_name, email,
     83password_hash, date_of_birth, rating, address_id, bio, street, municipality, city, number, country,
     84listing_title, available_from, available_to, listing_status, listing_description, unit_id, unit_number,
     85floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount, property_id, property_title,
     86property_description, created_at, property_type_id, property_type_name} **-Не ги содржи сите
     87атрибути. **
     88
     895.**document_id+** = {document_id, file_type, file_url, uploaded_at, user_id, lease_id,
     90first_name, last_name, email, password_hash, date_of_birth, rating, address_id, bio, street,
     91municipality, city, number, country, start_date, end_date, lease_rent_amount, deposit_amount,
     92listing_id, tenant_profile_id, landlord_profile_id, managed_properties_count, is_agent,
     93listing_title, available_from, available_to, listing_status, listing_description, unit_id, unit_number,
     94floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount, property_id, property_title,
     95property_description, created_at, property_type_id, property_type_name} **-Не ги содржи сите
     96атрибути.**
     97
     986.** message_id+** = {message_id, sent_at, content, user_id, lease_id, first_name, last_name,
     99email, password_hash, date_of_birth, rating, address_id, bio, street, municipality, city, number,
     100country, start_date, end_date, lease_rent_amount, deposit_amount, listing_id, tenant_profile_id,
     101landlord_profile_id, managed_properties_count, is_agent, listing_title, available_from,
     102available_to, listing_status, listing_description, unit_id, unit_number, floor, bedrooms,
     103bathrooms, area_sq_m, unit_rent_amount, property_id, property_title, property_description,
     104created_at, property_type_id, property_type_name} **-Не ги содржи сите атрибути.**
     105
     1067.** unit_image_id+** = {unit_image_id, unit_image, unit_id, unit_number, floor, bedrooms,
     107bathrooms, area_sq_m, unit_rent_amount, property_id, property_title, property_description,
     108created_at, user_id, property_type_id, address_id, first_name, last_name, email,
     109password_hash, date_of_birth, rating, bio, street, municipality, city, number, country,
     110property_type_name}**-Не ги содржи сите атрибути.**
     111
     1128.** tenant_profile_id+** = {tenant_profile_id, user_id, first_name, last_name, email,
     113password_hash, date_of_birth, rating, address_id, bio, street, municipality, city, number,
     114country} **-Не ги содржи сите атрибути.**
     115 
     116
     117==== Започнуваме со комбинирање на покривачите за да дојдеме до сите атрибути:
     1181.** {property_image_id, payment_id}+** = {property_image_id, property_image, property_id,
     119property_title, property_description, created_at, user_id, property_type_id, address_id,
     120property_type_name, street, municipality, city, number, country, first_name, last_name, email,
     121password_hash, date_of_birth, rating, bio, payment_id, amount, payment_status,
     122payment_date, lease_id, payment_method_id, payment_method_name, start_date, end_date,
     123lease_rent_amount, deposit_amount, listing_id, tenant_profile_id, landlord_profile_id,
     124listing_title, available_from, available_to, listing_status, listing_description, unit_id, unit_number,
     125floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount, managed_properties_count,
     126is_agent} **-Не ги содржи сите атрибути.**
     127
     1282.** {property_image_id, payment_id, maintenance_log_id}+** = {property_image_id,
     129property_image, property_id, property_title, property_description, created_at, user_id,
     130property_type_id, address_id, property_type_name, street, municipality, city, number, country,
     131first_name, last_name, email, password_hash, date_of_birth, rating, bio, payment_id, amount,
     132payment_status, payment_date, lease_id, payment_method_id, payment_method_name,
     133start_date, end_date, lease_rent_amount, deposit_amount, listing_id, tenant_profile_id,
     134landlord_profile_id, managed_properties_count, is_agent, listing_title, available_from,
     135available_to, listing_status, listing_description, unit_id, unit_number, floor, bedrooms,
     136bathrooms, area_sq_m, unit_rent_amount, maintenance_log_id, maintenance_description,
     137maintenance_date, service_request_id, service_description, request_date, service_status,
     138service_category_id, service_category_name} **-Не ги содржи сите атрибути. **
     139
     1403.** {property_image_id, payment_id, maintenance_log_id, inspection_id}+** = Со ова на
     141претходните се додаваат: inspection_id, inspection_date, notes **-Не ги содржи сите
     142атрибути.**
     143
     1444.** {property_image_id, payment_id, maintenance_log_id, inspection_id, document_id}+**= Со
     145ова на претходните се додаваат: document_id, file_type, file_url, uploaded_at -Не ги
     146содржи сите атрибути.
     147
     1485.** {property_image_id, payment_id, maintenance_log_id, inspection_id, document_id,
     149message_id}+** = Со ова на претходните се додаваат: message_id, sent_at, content ** -Не ги
     150содржи сите атрибути.**
     151
     1526.** {property_image_id, payment_id, maintenance_log_id, inspection_id, document_id,
     153message_id, unit_image_id}+**= Со ова на претходните се додаваат: message_id, sent_at,
     154content unit_image_id, unit_image **- Ги содржи сите атрибути!**
     155
     156Во овааа релација нема повеќекратни зависности и истата ја задоволува 1НФ.
     157Оваа релација не задоволува 2НФ поради постоење на парцијални зависности.
     158== Декомпозиција во 2НФ
     159За да ги отстраниме парцијалните зависности потребно е да ги оделиме атрибутите во
     160релации во кои целосно ќе зависат од нивниот клуч па тоа би го сториле на следен
     161начин:
     1621. property_image_id → property_image, property_id
     1632. payment_id → amount, payment_status, payment_date, lease_id, payment_method_id
     1643. maintenance_log_id → maintenance_description, maintenance_date,
     165service_request_id
     1664. inspection_id → inspection_date, notes, lease_id, landlord_profile_id
     1675. document_id → file_type, file_url, uploaded_at, user_id, lease_id
     1686. message_id → sent_at, content, user_id, lease_id
     1697. unit_image_id → unit_image, unit_id
     1708. tenant_profile_id → user_id
     171== Декомпозиција во релации
     172Овдека првин ќе ги извдоиме самите релации од погоре, но за самата декомпозиција да
     173може да се изведе подоцна, ќе ги издвоиме и релациите со примарни клучеви:
     174payment_method_id, service_category_id и service_request_id, односно релациите R1, R2 и
     175R5. Со ваква организација ќе ги тргнеме атрибутите пред самите клучеви кои ќе бидат
     176отстранети подоцна во релациите R5 (за service_category_id), R6 (за service_request_id) и
     177R4 (за payment_method_id). Конкретно, релациите ќе ги издвоиме поради следните
     178транзитивни зависности со кои не постигнуваме 3НФ:
     179*  payment_method_id → payment_method_name
     180*  service_category_id → service_category_name
     181*  service_request_id → service_description, request_date, service_status, lease_id, service_category_id
     182**R1 {payment_method_id, payment_method_name}**
     183
     184**R2 {service_category_id, service_category_name}**
     185
     186**R3 {property_image_id, property_image, property_id} - во BCNF
     187
     188**R4 {payment_id, amount, payment_status, payment_date, lease_id, payment_method_id}-во BCNF
     189
     190**R5 {service_request_id, service_description, request_date, service_status, lease_id,
     191service_category_id }
     192
     193**R6 {maintenance_log_id, maintenance_description, maintenance_date,
     194service_request_id} - во BCNF
     195
     196**R7 {inspection_id, inspection_date, notes, lease_id, landlord_profile_id} - во BCNF
     197
     198**R8 {document_id, file_type, file_url, uploaded_at, user_id, lease_id} - во BCNF
     199
     200**R9 {message_id, sent_at, content, user_id, lease_id} - во BCNF
     201
     202**R10 {unit_image_id, unit_image, unit_id} - во BCNF
     203
     204**R11 {tenant_profile_id, user_id} - во BCNF
     205
     206**R12** - остатокот од атрибутите: {property_image_id, payment_id, maintenance_log_id,
     207inspection_id, document_id, message_id, unit_image_id, tenant_profile_id, property_id,
     208property_type_id, unit_id, listing_id, lease_id, landlord_profile_id, address_id, user_id,
     209property_title, property_description, created_at, property_type_name, unit_number, floor,
     210bedrooms, bathrooms, area_sq_m, unit_rent_amount, listing_title, available_from, available_to,
     211listing_status, listing_description, start_date, end_date, lease_rent_amount, deposit_amount,
     212managed_properties_count, is_agent, street, municipality, city, number, country, first_name,
     213last_name, email, password_hash, date_of_birth, rating, bio}
     214
     215=== Проверка на 3НФ за R12
     216R12 не е во 3НФ поради следните транзитивни зависности:
     217
     218**Транзитивна зависност : property_id → user_id, property_type_id, address_id,
     219property_title, property_description, created_at
     220
     221R12.1 {property_id, user_id, property_type_id, address_id, property_title, property_description,
     222created_at} - не е во 3НФ
     223R12.1 не е во 3НФ поради:
     224• property_type_id → property_type_name
     225• address_id → street, municipality, city, number, country
     226• user_id → first_name, last_name, email, password_hash, date_of_birth, rating, bio
     227R12.1.1 {property_type_id, property_type_name} - во BCNF
     228R12.1.2 {address_id, street, municipality, city, number, country} - во BCNF
     229R12.1.3 {user_id, first_name, last_name, email, password_hash, date_of_birth, rating,
     230bio} - во BCNF
     231R12.1.4 {property_id, user_id, property_type_id, address_id, property_title,
     232property_description, created_at} - во BCNF
     233Во R12.2 остануваат сите атрибути кои ги нема во претходните релации.
     234R12.2 - {property_image_id, payment_id, maintenance_log_id, inspection_id, document_id,
     235message_id, unit_image_id, tenant_profile_id, property_id, unit_id, listing_id, lease_id,
     236landlord_profile_id, unit_number, floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount,
     237listing_title, available_from, available_to, listing_status, listing_description, start_date, end_date,
     238lease_rent_amount, deposit_amount, managed_properties_count, is_agent}.
     239--------------------------------------------------------------------------------------------------
     240R12.2 не е во 3НФ бидејќи unit_id → unit_number, floor, bedrooms, bathrooms, area_sq_m,
     241unit_rent_amount, property_id.
     242R12.2.1 {unit_id, unit_number, floor, bedrooms, bathrooms, area_sq_m,
     243unit_rent_amount, property_id} - во BCNF
     244R12.2.2 {property_image_id, payment_id, maintenance_log_id, inspection_id, document_id,
     245message_id, unit_image_id, tenant_profile_id, unit_id, listing_id, lease_id, landlord_profile_id,
     246listing_title, available_from, available_to, listing_status, listing_description, start_date, end_date,
     247lease_rent_amount, deposit_amount, managed_properties_count, is_agent}
     248R12.2.2 не е во 3НФ бидејќи listing_id → listing_title, available_from, available_to,
     249listing_status, listing_description, unit_id
     250R12.2.2.1 {listing_id, listing_title, available_from, available_to, listing_status,
     251listing_description, unit_id} - во BCNF
     252R12.2.2.2 {property_image_id, payment_id, maintenance_log_id, inspection_id, document_id,
     253message_id, unit_image_id, tenant_profile_id, listing_id, lease_id, landlord_profile_id,
     254start_date, end_date, lease_rent_amount, deposit_amount, managed_properties_count,
     255is_agent}
     256R12.2.2.2 не е во 3НФ бидејќи landlord_profile_id → managed_properties_count, is_agent
     257R12.2.2.2.1 { landlord_profile_id, managed_properties_count, is_agent } - во BCNF
     258R12.2.2.2.2 { property_image_id, payment_id, maintenance_log_id, inspection_id, document_id,
     259message_id, unit_image_id, tenant_profile_id, listing_id, lease_id, landlord_profile_id,
     260start_date, end_date, lease_rent_amount, deposit_amount}
     261-------------------------------------------------------
     262R12.2.2.2.2 не е во 3НФ бидејќи lease_id -> start_date, end_date, lease_rent_amount,
     263deposit_amount, listing_id, tenant_profile_id, landlord_profile_id
     264R12.2.2.2.2.1 {lease_id, start_date, end_date, lease_rent_amount, deposit_amount,
     265listing_id, tenant_profile_id, landlord_profile_id} - во BCNF
     266R12.2.2.2.2.2 { property_image_id, payment_id, maintenance_log_id, inspection_id,
     267document_id, message_id, unit_image_id} - во BCNF
     268Финални релации во BCNF
     2691. Property_Image {property_image_id, property_image, property_id} - во BCNF
     2702. Payment {payment_id, amount, payment_status, payment_date, lease_id,
     271payment_method_id} - во BCNF
     2723. Maintenance_Log {maintenance_log_id, maintenance_description, maintenance_date,
     273service_request_id} - во BCNF
     2744. Inspection {inspection_id, inspection_date, notes, lease_id, landlord_profile_id} - во
     275BCNF
     2765. Document {document_id, file_type, file_url, uploaded_at, user_id, lease_id} - во BCNF
     2776. Message {message_id, sent_at, content, from_user_id, to_user_id, lease_id} - во BCNF
     2787. Unit_Image {unit_image_id, unit_image, unit_id} - во BCNF
     2798. Tenant_Profile {tenant_profile_id, user_id} - во BCNF
     2809. Property_Type {property_type_id, property_type_name} - во BCNF
     28110. Address {address_id, street, municipality, city, number, country} - во BCNF
     28211. User {user_id, first_name, last_name, email, password_hash, date_of_birth, rating, bio}
     283- во BCNF
     28412. Property {property_id, user_id, property_type_id, address_id, property_title,
     285property_description, created_at} - во BCNF
     28613. Unit {unit_id, unit_number, floor, bedrooms, bathrooms, area_sq_m, unit_rent_amount,
     287property_id} - во BCNF
     28814. Listing {listing_id, listing_title, available_from, available_to, listing_status,
     289listing_description, unit_id} - во BCNF
     29015. Lease {lease_id, start_date, end_date, lease_rent_amount, deposit_amount, listing_id,
     291tenant_profile_id, landlord_profile_id} - во BCNF
     29216. Landlord_Profile {landlord_profile_id, managed_properties_count, is_agent} - во BCNF
     29317. Payment_Method {payment_method_id, payment_method_name} - во BCNF
     29418. Service_Request {service_request_id, service_description, request_date,
     295service_status, lease_id, service_category_id} - во BCNF
     29619. Service_Category {service_category_id, service_category_name} - во BCNF
     29720. Main_Relation {property_image_id, payment_id, maintenance_log_id, inspection_id,
     298document_id, message_id, unit_image_id} - во BCNF
     29921.Interested {listing_id, tenant_profile_id} - во BCNF