| 3 | | == Нормални форми по релации == |
| | 4 | {{{ |
| | 5 | Full(track_id, name, album_id, artist_id, media_type_id, genre_id, composer, |
| | 6 | milliseconds, bytes, price_id, value, date, |
| | 7 | invoice_line_id, invoice_id, quantity, |
| | 8 | customer_id, first_name, last_name, company, support_rep_id, personal_info_id, contact_id, |
| | 9 | employee_id, title, reports_to, birth_date, hire_date, |
| | 10 | address_info_id, address, city, state, country, postal_code, phone, fax, email, |
| | 11 | playlist_id, playlist_name, playlist_track_id) |
| | 12 | }}} |
| 8 | | ||= Релација =||= Клуч(еви) =||= Функциски зависности (ФЗ) =||= Нормална форма =|| |
| 9 | | ||'''Full(track_id, name, album_id, artist_id, media_type_id, genre_id, composer, milliseconds, bytes, price_id, value, date, invoice_line_id, invoice_id, quantity, customer_id, first_name, last_name, company, support_rep_id, personal_info_id, contact_id, employee_id, title, reports_to, birth_date, hire_date, address_info_id, address, city, state, country, postal_code, phone, fax, email, playlist_id, playlist_name, playlist_track_id)'''||track_id, album_id, artist_id, media_type_id, genre_id, price_id, invoice_line_id, invoice_id, customer_id, employee_id, address_info_id, contact_id, playlist_id, playlist_track_id||Многу функционални зависности (track_id → {...}, album_id → {...}, artist_id → name, ...)||1NF|| |
| | 16 | '''Track''' |
| 14 | | ||= Релација =||= Клуч(еви) =||= Функциски зависности (ФЗ) =||= Нормална форма =|| |
| 15 | | ||'''Track(track_id, name, album_id, media_type_id, genre_id, composer, milliseconds, bytes)'''||track_id||track_id → {name, album_id, media_type_id, genre_id, composer, milliseconds, bytes}||BCNF|| |
| 16 | | ||'''Album(album_id, title, artist_id)'''||album_id||album_id → {title, artist_id}||BCNF|| |
| 17 | | ||'''Artist(artist_id, name)'''||artist_id||artist_id → name||BCNF|| |
| 18 | | ||'''Genre(genre_id, name)'''||genre_id||genre_id → name||BCNF|| |
| 19 | | ||'''!MediaType(media_type_id, name)'''||media_type_id||media_type_id → name||BCNF|| |
| | 22 | price_id → value, date, track_id |
| 40 | | |
| 41 | | ||= Релација =||= Клуч(еви) =||= Функциски зависности (ФЗ) =||= Нормална форма =|| |
| 42 | | ||'''Customer(customer_id, first_name, last_name, company, support_rep_id, personal_info_id, contact_id)'''||customer_id||customer_id → {first_name, last_name, company, support_rep_id, personal_info_id, contact_id}||BCNF|| |
| 43 | | ||'''Employee(employee_id, first_name, last_name, title, reports_to, birth_date, hire_date, personal_info_id, contact_id)'''||employee_id||employee_id → {first_name, last_name, title, reports_to, birth_date, hire_date, personal_info_id, contact_id}||BCNF|| |
| 44 | | ||'''!AddressInfo(address_info_id, address, city, state, country, postal_code)'''||address_info_id||address_info_id → {address, city, state, country, postal_code}||BCNF|| |
| 45 | | ||'''Contact(contact_id, phone, fax, email)'''||contact_id||contact_id → {phone, fax, email}||BCNF|| |
| | 46 | address_info_id → address, city, state, country, postal_code, phone, fax, email |
| 57 | | ||= Релација =||= Клуч(еви) =||= Функциски зависности (ФЗ) =||= Нормална форма =|| |
| 58 | | ||'''Track(track_id, name, album_id, media_type_id, genre_id, composer, milliseconds, bytes)'''||track_id||track_id → {name, album_id, media_type_id, genre_id, composer, milliseconds, bytes}||BCNF|| |
| 59 | | ||'''Album(album_id, title, artist_id)'''||album_id||album_id → {title, artist_id}||BCNF|| |
| 60 | | ||'''Artist(artist_id, name)'''||artist_id||artist_id → name||BCNF|| |
| 61 | | ||'''Genre(genre_id, name)'''||genre_id||genre_id → name||BCNF|| |
| 62 | | ||'''!MediaType(media_type_id, name)'''||media_type_id||media_type_id → name||BCNF|| |
| 63 | | ||'''Price(price_id, value, date, track_id)'''||price_id (и можен (date, track_id))||price_id → {value, date, track_id}||BCNF|| |
| 64 | | ||'''!InvoiceLine(invoice_line_id, invoice_id, track_id, quantity)'''||invoice_line_id (и можен (invoice_id, track_id))||(invoice_line_id → {invoice_id, track_id, quantity})||BCNF|| |
| 65 | | ||'''Invoice(invoice_id, customer_id, invoice_date, billing_address, billing_city, billing_state, billing_country, billing_postal_code, total)'''||invoice_id||invoice_id → {customer_id, invoice_date, billing_address, billing_city, billing_state, billing_country, billing_postal_code, total}||BCNF|| |
| 66 | | ||'''Customer(customer_id, first_name, last_name, company, support_rep_id, personal_info_id, contact_id)'''||customer_id||customer_id → {first_name, last_name, company, support_rep_id, personal_info_id, contact_id}||BCNF|| |
| 67 | | ||'''Employee(employee_id, first_name, last_name, title, reports_to, birth_date, hire_date, personal_info_id, contact_id)'''||employee_id||employee_id → {first_name, last_name, title, reports_to, birth_date, hire_date, personal_info_id, contact_id}||BCNF|| |
| 68 | | ||'''!AddressInfo(address_info_id, address, city, state, country, postal_code)'''||address_info_id||address_info_id → {address, city, state, country, postal_code}||BCNF|| |
| 69 | | ||'''Contact(contact_id, phone, fax, email)'''||contact_id||contact_id → {phone, fax, email}||BCNF|| |
| 70 | | ||'''Playlist(playlist_id, name)'''||playlist_id||playlist_id → name||BCNF|| |
| 71 | | ||'''!PlaylistTrack(playlist_track_id, playlist_id, track_id)'''||playlist_track_id (и можен (playlist_id, track_id))||playlist_track_id → {playlist_id, track_id}||BCNF|| |
| | 58 | Сите атрибути се атомарни → релацијата е во 1NF. |
| | 68 | === 4.1 Track === |
| | 69 | {{{ |
| | 70 | Track(track_id, name, album_id, media_type_id, genre_id, composer, milliseconds, bytes) |
| | 71 | PK: track_id |
| | 72 | }}} |
| | 73 | |
| | 74 | === 4.2 Price === |
| | 75 | {{{ |
| | 76 | Price(price_id, value, date, track_id) |
| | 77 | PK: price_id |
| | 78 | FK: track_id → Track(track_id) |
| | 79 | }}} |
| | 80 | |
| | 81 | === 4.3 Album === |
| | 82 | {{{ |
| | 83 | Album(album_id, artist_id) |
| | 84 | PK: album_id |
| | 85 | FK: artist_id → Artist(artist_id) |
| | 86 | }}} |
| | 87 | |
| | 88 | === 4.4 Artist === |
| | 89 | {{{ |
| | 90 | Artist(artist_id, artist_name) |
| | 91 | PK: artist_id |
| | 92 | }}} |
| | 93 | |
| | 94 | === 4.5 InvoiceLine === |
| | 95 | {{{ |
| | 96 | InvoiceLine(invoice_line_id, invoice_id, track_id, quantity) |
| | 97 | PK: invoice_line_id |
| | 98 | FK: invoice_id → Invoice(invoice_id) |
| | 99 | FK: track_id → Track(track_id) |
| | 100 | }}} |
| | 101 | |
| | 102 | === 4.6 Invoice === |
| | 103 | {{{ |
| | 104 | Invoice(invoice_id, customer_id) |
| | 105 | PK: invoice_id |
| | 106 | FK: customer_id → Customer(customer_id) |
| | 107 | }}} |
| | 108 | |
| | 109 | === 4.7 Customer === |
| | 110 | {{{ |
| | 111 | Customer(customer_id, first_name, last_name, company, support_rep_id, personal_info_id, contact_id) |
| | 112 | PK: customer_id |
| | 113 | FK: support_rep_id → Employee(employee_id) |
| | 114 | }}} |
| | 115 | |
| | 116 | === 4.8 Employee === |
| | 117 | {{{ |
| | 118 | Employee(employee_id, title, reports_to, birth_date, hire_date) |
| | 119 | PK: employee_id |
| | 120 | }}} |
| | 121 | |
| | 122 | === 4.9 AddressInfo === |
| | 123 | {{{ |
| | 124 | AddressInfo(address_info_id, address, city, state, country, postal_code, phone, fax, email) |
| | 125 | PK: address_info_id |
| | 126 | }}} |
| | 127 | |
| | 128 | === 4.10 Playlist === |
| | 129 | {{{ |
| | 130 | Playlist(playlist_id, playlist_name) |
| | 131 | PK: playlist_id |
| | 132 | }}} |
| | 133 | |
| | 134 | === 4.11 PlaylistTrack === |
| | 135 | {{{ |
| | 136 | PlaylistTrack(playlist_track_id, playlist_id, track_id) |
| | 137 | PK: playlist_track_id |
| | 138 | FK: playlist_id → Playlist(playlist_id) |
| | 139 | FK: track_id → Track(track_id) |
| | 140 | }}} |
| | 141 | |
| | 142 | == 5. Трета нормална форма (3NF) == |
| | 143 | |
| | 144 | album_id → artist_id → Artist е одвоен. |
| | 145 | |
| | 146 | support_rep_id → Employee е FK, нема транзитивна зависност во Customer. |
| | 147 | |
| | 148 | Адресата е изнесена во AddressInfo. |
| | 149 | |
| | 150 | Сите не-клучни атрибути зависат директно од клучевите. |
| | 151 | |
| | 152 | ✅ Сега сите релации се во 3NF. |
| | 153 | |
| | 154 | == Финален нормализиран модел (3NF) == |
| | 155 | |
| | 156 | {{{ |
| | 157 | Track(track_id, name, album_id, media_type_id, genre_id, composer, milliseconds, bytes) |
| | 158 | |
| | 159 | Price(price_id, value, date, track_id) |
| | 160 | |
| | 161 | Album(album_id, artist_id) |
| | 162 | |
| | 163 | Artist(artist_id, artist_name) |
| | 164 | |
| | 165 | InvoiceLine(invoice_line_id, invoice_id, track_id, quantity) |
| | 166 | |
| | 167 | Invoice(invoice_id, customer_id) |
| | 168 | |
| | 169 | Customer(customer_id, first_name, last_name, company, support_rep_id, personal_info_id, contact_id) |
| | 170 | |
| | 171 | Employee(employee_id, title, reports_to, birth_date, hire_date) |
| | 172 | |
| | 173 | AddressInfo(address_info_id, address, city, state, country, postal_code, phone, fax, email) |
| | 174 | |
| | 175 | Playlist(playlist_id, playlist_name) |
| | 176 | |
| | 177 | PlaylistTrack(playlist_track_id, playlist_id, track_id) |
| | 178 | }}} |