| | 155 | === RELATIONS === |
| | 156 | [[BR]] |
| | 157 | {{{receives (User – Notification)}}} |
| | 158 | [[BR]] |
| | 159 | Represents that a specific user receives specific notifications. It is needed so each notification is clearly assigned to one user. The relationship is modeled as 1–N: one user can receive many notifications; each notification belongs to exactly one user. |
| | 160 | [[BR]] |
| | 161 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 162 | * Identified by {{{notification_id}}} (PK of Notification). |
| | 163 | * On the relationship level, the pair ({{{user_id}}}, {{{notification_id}}}) is unique. |
| | 164 | [[BR]] |
| | 165 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 166 | No extra attributes apart from the foreign keys already listed: {{{user_id}}} in Notification. |
| | 167 | ---- |
| | 168 | [[BR]] |
| | 169 | {{{made_by (User – Listing)}}} |
| | 170 | [[BR]] |
| | 171 | Links each listing to the user who created it. It is needed to track authorship, rights to modify the listing, and contact information. Modeled as 1–N because one user can create many listings, but each listing is created by exactly one user. |
| | 172 | [[BR]] |
| | 173 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 174 | * Identified by {{{listing_id}}}. |
| | 175 | * The pair ({{{user_id}}}, {{{listing_id}}}) is unique. |
| | 176 | [[BR]] |
| | 177 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 178 | Relationship implemented via foreign key {{{user_id}}} inside Listing. |
| | 179 | [[BR]] |
| | 180 | ---- |
| | 181 | {{{made_for (Listing – Animal)}}} |
| | 182 | [[BR]] |
| | 183 | Shows that a listing is created for a specific animal. It is needed to attach each advertisement to the animal being sold or adopted. Modeled as 1–N from Animal to Listing: one animal may appear in multiple listings, but each listing refers to exactly one animal. |
| | 184 | [[BR]] |
| | 185 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 186 | * Identified by {{{listing_id}}}. |
| | 187 | * The combination ({{{listing_id}}}, {{{animal_id}}}) is unique. |
| | 188 | [[BR]] |
| | 189 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 190 | Relationship implemented through the foreign key {{{animal_id}}} in Listing. |
| | 191 | [[BR]] |
| | 192 | ---- |
| | 193 | {{{owns (User – Animal)}}} |
| | 194 | [[BR]] |
| | 195 | Represents ownership of animals. It ensures that only the rightful owner can manage listings or initiate health-related actions. Modeled as 1–N: one user can own many animals, while each animal has exactly one current owner. |
| | 196 | [[BR]] |
| | 197 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 198 | * Identified by {{{animal_id}}}. |
| | 199 | * Unique pair ({{{owner_id}}}, {{{animal_id}}}). |
| | 200 | [[BR]] |
| | 201 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 202 | Foreign key {{{owner_id}}} is stored in Animal. |
| | 203 | ---- |
| | 204 | [[BR]] |
| | 205 | {{{writes (User – Review)}}} |
| | 206 | [[BR]] |
| | 207 | Represents that a user writes a review. Critical for establishing authorship and preventing anonymous reviews. Modeled as 1–N: one user can write many reviews, while each review has exactly one author. |
| | 208 | [[BR]] |
| | 209 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 210 | * Identified by {{{review_id}}}. |
| | 211 | * Unique pair ({{{reviewer_id}}}, {{{review_id}}}). |
| | 212 | [[BR]] |
| | 213 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 214 | Foreign key {{{reviewer_id}}} appears in Review. |
| | 215 | ---- |
| | 216 | [[BR]] |
| | 217 | {{{user_reviewed_in (User – Review)}}} |
| | 218 | [[BR]] |
| | 219 | Represents that a user is the target of a review (e.g., a seller rated by a buyer). Needed for calculating user reputation. Modeled as 1–N: one user can receive many reviews, while each review may refer to one target user. |
| | 220 | [[BR]] |
| | 221 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 222 | * Identified by {{{review_id}}}. |
| | 223 | * The pair ({{{target_user_id}}}, {{{review_id}}}) is unique. |
| | 224 | [[BR]] |
| | 225 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 226 | Foreign key {{{target_user_id}}} in Review (may be NULL when reviewing a clinic). |
| | 227 | ---- |
| | 228 | [[BR]] |
| | 229 | {{{clinic_reviewed_in (VetClinic – Review)}}} |
| | 230 | [[BR]] |
| | 231 | Represents that a clinic is the target of a review. This supports public ratings of veterinary clinics. Modeled as 1–N: one clinic can receive many reviews; each review may refer to a single clinic. |
| | 232 | [[BR]] |
| | 233 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 234 | * Identified by {{{review_id}}}. |
| | 235 | * Unique pair ({{{target_clinic_id}}}, {{{review_id}}}). |
| | 236 | [[BR]] |
| | 237 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 238 | Foreign key {{{target_clinic_id}}} stored in Review (NULL if review is about a user). |
| | 239 | ---- |
| | 240 | [[BR]] |
| | 241 | {{{belongs_to (Animal – HealthRecord)}}} |
| | 242 | |
| | 243 | [[BR]] |
| | 244 | Connects each medical record entry to the animal it describes. It is essential for maintaining a full medical history. Modeled as 1–N: one animal has many health records, while each health record refers to one animal. |
| | 245 | [[BR]] |
| | 246 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 247 | * Identified by {{{healthrecord_id}}}. |
| | 248 | * Unique pair ({{{animal_id}}}, {{{healthrecord_id}}}). |
| | 249 | [[BR]] |
| | 250 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 251 | Foreign key {{{animal_id}}} is stored in HealthRecord. |
| | 252 | ---- |
| | 253 | [[BR]] |
| | 254 | {{{at_appointment (Appointment – HealthRecord)}}} |
| | 255 | |
| | 256 | [[BR]] |
| | 257 | Represents that a health record entry was created during a specific appointment. Needed to link treatments and checkups to their corresponding visits. Modeled as 1–N: one appointment may generate many records; each record belongs to at most one appointment. |
| | 258 | [[BR]] |
| | 259 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 260 | * Identified by {{{healthrecord_id}}}. |
| | 261 | * Unique pair ({{{appointment_id}}}, {{{healthrecord_id}}}). |
| | 262 | [[BR]] |
| | 263 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 264 | Foreign key {{{appointment_id}}} included in HealthRecord (may be NULL if manually added). |
| | 265 | ---- |
| | 266 | [[BR]] |
| | 267 | {{{at_what_clinic (VetClinic – Appointment)}}} |
| | 268 | [[BR]] |
| | 269 | Represents at which veterinary clinic a given appointment takes place. This allows the system to know the location of each visit, show a clinic’s schedule, and coordinate resources. Modeled as 1–N: one clinic can host many appointments, while each appointment is held at exactly one clinic. |
| | 270 | [[BR]] |
| | 271 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 272 | * Identified by {{{appointment_id}}}. |
| | 273 | * Unique pair ({{{clinic_id}}}, {{{appointment_id}}}). |
| | 274 | [[BR]] |
| | 275 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 276 | Foreign key {{{clinic_id}}} stored in {{{Appointment}}}. |
| | 277 | ---- |
| | 278 | [[BR]] |
| | 279 | {{{for_animal (Animal – Appointment)}}} |
| | 280 | [[BR]] |
| | 281 | Represents which animal a given appointment is scheduled for. It is needed so every appointment is clearly tied to a specific pet, enabling the system to show that pet’s upcoming visits and history. The relationship is modeled as 1–N from Animal to Appointment: one animal can have many appointments over time, while each appointment refers to exactly one animal. |
| | 282 | [[BR]] |
| | 283 | '''[[span(style=color: #E30B5C, Keys: )]]''' |
| | 284 | * Identified by {{{appointment_id}}} (PK of Appointment). |
| | 285 | * On the relationship level, the pair ({{{animal_id}}}, {{{appointment_id}}}) is unique. |
| | 286 | [[BR]] |
| | 287 | '''[[span(style=color: #E30B5C, Attributes: )]]''' |
| | 288 | No extra attributes apart from the foreign key {{{animal_id}}} stored in {{{Appointment}}}. |