| 106 | | The closure K+ contains all attributes of the universal relation R. Therefore, K is a superkey. Each attribute in K is necessary because removing any one of them prevents at least one set of attributes of R from being derived. Therefore, K is minimal and the selected primary key for the initial de-normalized relation is: |
| 107 | | |
| 108 | | **(order_id, product_id, artist_id, song_id, modification_id, album_id)** |
| | 118 | To verify that K is a superkey, we calculate its closure. |
| | 119 | |
| | 120 | We start with: |
| | 121 | |
| | 122 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id}** |
| | 123 | |
| | 124 | Using: |
| | 125 | |
| | 126 | `order_id → user_id, payment_method, purchase_date, points_earned, points_used, status` |
| | 127 | |
| | 128 | we obtain: |
| | 129 | |
| | 130 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status}** |
| | 131 | |
| | 132 | Using: |
| | 133 | |
| | 134 | `user_id → email, username, password, date_created, shipping_address, telephone_number` |
| | 135 | |
| | 136 | we obtain: |
| | 137 | |
| | 138 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number}** |
| | 139 | |
| | 140 | Using: |
| | 141 | |
| | 142 | `user_id → points_collected` |
| | 143 | |
| | 144 | and: |
| | 145 | |
| | 146 | `user_id → wishlist_id` |
| | 147 | |
| | 148 | we obtain: |
| | 149 | |
| | 150 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id}** |
| | 151 | |
| | 152 | Using: |
| | 153 | |
| | 154 | `product_id → release_id, format, price, product_description, stock` |
| | 155 | |
| | 156 | we obtain: |
| | 157 | |
| | 158 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock}** |
| | 159 | |
| | 160 | Using: |
| | 161 | |
| | 162 | `release_id → title, record_label, genre, release_date, cover_photo, duration` |
| | 163 | |
| | 164 | we obtain: |
| | 165 | |
| | 166 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration}** |
| | 167 | |
| | 168 | Using: |
| | 169 | |
| | 170 | `artist_id → artist_name, artist_description, artist_photo` |
| | 171 | |
| | 172 | we obtain: |
| | 173 | |
| | 174 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo}** |
| | 175 | |
| | 176 | Using: |
| | 177 | |
| | 178 | `song_id → song_name, song_duration` |
| | 179 | |
| | 180 | we obtain: |
| | 181 | |
| | 182 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration}** |
| | 183 | |
| | 184 | Using: |
| | 185 | |
| | 186 | `modification_id → admin_id, date_modified, type_of_modification, discount` |
| | 187 | |
| | 188 | we obtain: |
| | 189 | |
| | 190 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration, admin_id, date_modified, type_of_modification, discount}** |
| | 191 | |
| | 192 | Using the corrected dependency: |
| | 193 | |
| | 194 | `admin_id → admin_type, discount_percentage` |
| | 195 | |
| | 196 | we obtain: |
| | 197 | |
| | 198 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration, admin_id, date_modified, type_of_modification, discount, admin_type, discount_percentage}** |
| | 199 | |
| | 200 | Since both `order_id` and `product_id` are now present, using: |
| | 201 | |
| | 202 | `(order_id, product_id) → price_at_purchase, quantity` |
| | 203 | |
| | 204 | we obtain: |
| | 205 | |
| | 206 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration, admin_id, date_modified, type_of_modification, discount, admin_type, discount_percentage, price_at_purchase, quantity}** |
| | 207 | |
| | 208 | Using: |
| | 209 | |
| | 210 | `(wishlist_id, product_id) → added_at` |
| | 211 | |
| | 212 | we obtain: |
| | 213 | |
| | 214 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration, admin_id, date_modified, type_of_modification, discount, admin_type, discount_percentage, price_at_purchase, quantity, added_at}** |
| | 215 | |
| | 216 | Using: |
| | 217 | |
| | 218 | `(release_id, artist_id) → release_ordinal, type` |
| | 219 | |
| | 220 | we obtain: |
| | 221 | |
| | 222 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration, admin_id, date_modified, type_of_modification, discount, admin_type, discount_percentage, price_at_purchase, quantity, added_at, release_ordinal, type}** |
| | 223 | |
| | 224 | Using: |
| | 225 | |
| | 226 | `(song_id, artist_id) → song_ordinal` |
| | 227 | |
| | 228 | we obtain: |
| | 229 | |
| | 230 | **K+ = {order_id, product_id, artist_id, song_id, modification_id, album_id, user_id, payment_method, purchase_date, points_earned, points_used, status, email, username, password, date_created, shipping_address, telephone_number, points_collected, wishlist_id, release_id, format, price, product_description, stock, title, record_label, genre, release_date, cover_photo, duration, artist_name, artist_description, artist_photo, song_name, song_duration, admin_id, date_modified, type_of_modification, discount, admin_type, discount_percentage, price_at_purchase, quantity, added_at, release_ordinal, type, song_ordinal}** |
| | 231 | |
| | 232 | Therefore: |
| | 233 | |
| | 234 | **K+ = R**, so K is a superkey. |
| | 235 | |
| | 236 | Therefore, under the current set of functional dependencies: |
| | 237 | |
| | 238 | **K = {order_id, product_id, artist_id, song_id, modification_id, album_id}** |
| | 239 | |
| | 240 | is a candidate key of the universal relation R. |
| | 241 | |