62 | | !WishId += {!UserId, Priority, !BookId, Title, Author, Language, !ImageURL, FirstName, LastName, Email, Username, Password, City, Neighborhood, Bio, Quote} |
63 | | |
64 | | Не ги содржи сите атрибути |
65 | | |
66 | | !SwapId += {!TransactionId, !RequestId, !UserId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, !BookId, !RequestStatus, !RequestDate, FirstName, LastName, Email, Username, Password, City, Neighborhood, Bio, Quote, Availability, Condition, Title, Author, Language, !ImageURL} |
67 | | |
68 | | Не ги содржи сите атрибути |
69 | | |
70 | | !ReviewId += {!TransactionId, !UserId, Rating, !ReviewerComment, !ReviewDate, !RequestId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, FirstName, LastName, Email, Username, Password, City, Neighborhood, Bio, Quote, !BookId, !RequestStatus, !RequestDate, Availability, Condition, Title, Author, Language, !ImageURL} |
| 62 | !WishId += {!UserId, Priority, !BookId, Title, Author, Language, !ImageURL, !FirstName, !LastName, Email, Username, Password, City, Neighborhood, Bio, Quote} |
| 63 | |
| 64 | Не ги содржи сите атрибути |
| 65 | |
| 66 | !SwapId += {!TransactionId, !RequestId, !UserId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, !BookId, !RequestStatus, !RequestDate, !FirstName, !LastName, Email, Username, Password, City, Neighborhood, Bio, Quote, Availability, Condition, Title, Author, Language, !ImageURL} |
| 67 | |
| 68 | Не ги содржи сите атрибути |
| 69 | |
| 70 | !ReviewId += {!TransactionId, !UserId, Rating, !ReviewerComment, !ReviewDate, !RequestId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, !FirstName, !LastName, Email, Username, Password, City, Neighborhood, Bio, Quote, !BookId, !RequestStatus, !RequestDate, Availability, Condition, Title, Author, Language, !ImageURL} |
| 84 | ---- |
| 85 | |
| 86 | Да претпоставиме дека првата ФЗ што прави проблем е !BookId → Title. |
| 87 | |
| 88 | Првичната релација R која ги содржи сите атрибути, ја декомпонираме на R1 и R2. Во R1 мора да биде атрибутот !BookId, заедно со сите атрибути што се поврзани со него, додека останатите атрибути одат во R2. !BookId станува заеднички атрибут за R1 и R2, за да може да се прави спојување без загуба. |
| 89 | |
| 90 | R1 = {**!BookId**, Title, Author, Language, ImageURL} |
| 91 | |
| 92 | Примарен клуч: !BookId |
| 93 | |
| 94 | ФЗ: !BookId -> Title, Author, Language, ImageURL |
| 95 | |
| 96 | На левата страна од ФЗ имаме суперклуч, ваквата релација R1 е во БКНФ, и понатаму не ја декомпонираме. |
| 97 | |
| 98 | ---- |
| 99 | |
| 100 | R2 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, Rating, !ReviewerComment, !ReviewDate, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, !FirstName, !LastName, Email, Username, Password, City, Neighborhood, Bio, Quote, Availability, Condition, **!BookId**, ISBN, Genre, Priority, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity, !MessageId, !FriendshipId, !RequestId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 101 | |
| 102 | R2 е се уште во 2НФ поради останатите парцијални зависности. Една од нив е !UserId -> FirstName. За да го решиме ова, ќе го ставиме !UserId во посебна релација R3, заедно со сите атрибути поврзани со него, а сите останати атрибути ги пренесуваме во R4, заедно со !UserId како заеднички атрибут. |
| 103 | |
| 104 | ---- |
| 105 | |
| 106 | R3 = {**!UserId**, !FirstName, !LastName, Email, Username, Password, City, Neighborhood, Bio, Quote} |
| 107 | |
| 108 | Кандидат клуч: !UserId, Email, Username |
| 109 | |
| 110 | Примарен атрибут: !UserId, Email, Username |
| 111 | |
| 112 | ---- |
| 113 | |
| 114 | На ист начин продолжуваме понатаму се додека има парцијални зависности и додека не ги доведеме релациите во БКНФ: |
| 115 | |
| 116 | R4 = {!ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, **!UserId**, Rating, !ReviewerComment, !ReviewDate, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, Availability, Condition, !BookId, ISBN, Genre, Priority, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity, !MessageId, !FriendshipId, !RequestId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 117 | |
| 118 | |
| 119 | ---- |
| 120 | |
| 121 | R5 = {**!BookISBNId**, ISBN} |
| 122 | |
| 123 | ---- |
| 124 | |
| 125 | R6 = { !ReviewId, **!BookISBNId**, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, Rating, !ReviewerComment, !ReviewDate, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, Availability, Condition, !BookId, Genre, Priority, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity, !MessageId, !FriendshipId, !RequestId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 126 | |
| 127 | ---- |
| 128 | |
| 129 | R7 = {**!GenreId**, Genre} |
| 130 | |
| 131 | ---- |
| 132 | |
| 133 | R8 = { !ReviewId, !BookISBNId, **!GenreId**, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, Rating, !ReviewerComment, !ReviewDate, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, Availability, Condition, !BookId, Priority, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity, !MessageId, !FriendshipId, !RequestId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 134 | |
| 135 | ---- |
| 136 | |
| 137 | R9 = {**!ReviewId**, Rating, !ReviewerComment, !ReviewDate} |
| 138 | |
| 139 | ---- |
| 140 | |
| 141 | R10 = { **!ReviewId**, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, !Availability, !Condition, !BookId, !Priority, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity, !MessageId, !FriendshipId, !RequestId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 142 | |
| 143 | ---- |
| 144 | |
| 145 | R11 = {**!ReportId**, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity} |
| 146 | |
| 147 | ---- |
| 148 | |
| 149 | R12 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, **!ReportId**, !NotificationId, !TransactionId, !UserId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, Availability, Condition, !BookId, Priority, !MessageId, !FriendshipId, !RequestId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 150 | |
| 151 | ---- |
| 152 | |
| 153 | R13 = {**!NotificationId**, Type, !NotifTime, !NotifDate, Description, !NotificationStatus} |
| 154 | |
| 155 | ---- |
| 156 | |
| 157 | R14 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, **!NotificationId**, !TransactionId, !UserId, !InventoryId, !BorrowDate, !ReturnDate, !BorrowDuration, Availability, Condition, !BookId, Priority, !MessageId, !FriendshipId, !RequestId, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 158 | |
| 159 | ---- |
| 160 | |
| 161 | R15 = {**!TransactionId**, !BorrowDate, !ReturnDate, !BorrowDuration} |
| 162 | |
| 163 | ---- |
| 164 | |
| 165 | R16 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, **!TransactionId**, !UserId, !InventoryId, Availability, Condition, !BookId, Priority, !MessageId, !FriendshipId, !RequestId, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 166 | |
| 167 | ---- |
| 168 | |
| 169 | R17 = {**!InventoryId**, Availability, Condition} |
| 170 | |
| 171 | ---- |
| 172 | |
| 173 | R18 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, **!InventoryId**, !BookId, Priority, !MessageId, !FriendshipId, !RequestId, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 174 | |
| 175 | ---- |
| 176 | |
| 177 | R19 = {**!WishId**, Priority} |
| 178 | |
| 179 | ---- |
| 180 | |
| 181 | R20 = { !ReviewId, !BookISBNId, !GenreId, **!WishId**, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, !InventoryId, !BookId, !MessageId, !FriendshipId, !RequestId, !MsgTime, !MsgDate, !MessageContent, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 182 | |
| 183 | ---- |
| 184 | |
| 185 | R21 = {**!MessageId**, !MsgTime, !MsgDate, !MessageContent} |
| 186 | |
| 187 | ---- |
| 188 | |
| 189 | R22 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, !InventoryId, !BookId, **!MessageId**, !FriendshipId, !RequestId, !DateCreated, !FriendshipStatus, !RequestStatus, !RequestDate} |
| 190 | |
| 191 | ---- |
| 192 | |
| 193 | R23 = {**!FriendshipId**, !DateCreated, !FriendshipStatus} |
| 194 | |
| 195 | ---- |
| 196 | |
| 197 | R24 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, !InventoryId, !BookId, !MessageId, **!FriendshipId**, !RequestId, !RequestStatus, !RequestDate} |
| 198 | |
| 199 | ---- |
| 200 | |
| 201 | R25 = {**!RequestId**, !RequestStatus, !RequestDate} |
| 202 | |
| 203 | ---- |
| 204 | |
| 205 | R26 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, !InventoryId, !BookId, !MessageId, !FriendshipId, **!RequestId**} |
| 206 | |
| 207 | === Резултат од декомпозиција |
| 208 | |
| 209 | Краен резултат од релациите добиени по декомпозицијата (сите се во BCNF): |
| 210 | |
| 211 | Book |
| 212 | R1 = {!BookId, Title, Author, Language, ImageURL} |
| 213 | |
| 214 | !AppUser |
| 215 | R3 = {!UserId, !FirstName, !LastName, Email, Username, Password, City, Neighborhood, Bio, Quote, } |
| 216 | |
| 217 | !BookISBN |
| 218 | R5 = {!BookISBNId, ISBN} |
| 219 | |
| 220 | Genre |
| 221 | R7 = {!GenreId, Genre} |
| 222 | |
| 223 | Review |
| 224 | R9 = {!ReviewId, Rating, !ReviewerComment, !ReviewDate} |
| 225 | |
| 226 | Report |
| 227 | R11 = {!ReportId, !ReportType, !ReportDate, Details, !ReportStatus, !ReportedEntity} |
| 228 | |
| 229 | Notification |
| 230 | R13 = {!NotificationId, Type, !NotifTime, !NotifDate, Description, !NotificationStatus} |
| 231 | |
| 232 | Transaction |
| 233 | R15 = {!TransactionId, !BorrowDate, !ReturnDate, !BorrowDuration} |
| 234 | |
| 235 | !LibraryBook |
| 236 | R17 = {!InventoryId, Availability, Condition} |
| 237 | |
| 238 | !WishlistBook |
| 239 | R19 = {!WishId, Priority} |
| 240 | |
| 241 | Message |
| 242 | R21 = {!MessageId, !MsgTime, !MsgDate, !MessageContent} |
| 243 | |
| 244 | Friendship |
| 245 | R23 = {!FriendshipId, !DateCreated, !FriendshipStatus} |
| 246 | |
| 247 | !BookRequest |
| 248 | R25 = {!RequestId, !RequestStatus, !RequestDate} |
| 249 | |
| 250 | Evidencija |
| 251 | R26 = { !ReviewId, !BookISBNId, !GenreId, !WishId, !SwapId, !ReportId, !NotificationId, !TransactionId, !UserId, !InventoryId, !BookId, !MessageId, !FriendshipId, !RequestId} |
| 252 | |
| 253 | |
| 254 | * Со овој чекор на нормализација, сегашните табели се поразлични од претходните фази, и на овој начин ќе се продолжи во следната фаза. |