| | 1 | == Use-case 0003 - Add a Pet |
| | 2 | '''Initiating actor:''' Pet Owner |
| | 3 | |
| | 4 | '''Other actors:''' None |
| | 5 | |
| | 6 | '''Description:''' |
| | 7 | A pet owner wants to add a new animal to their profile so they can request services for it. The system provides available pet categories for them to choose from, and then saves the new pet profile into the database. |
| | 8 | |
| | 9 | '''Scenario:''' |
| | 10 | 1. Pet Owner opens the "My Pets" page and clicks "Add new pet". |
| | 11 | 2. System fetches all available pet species so the user can select one from a dropdown menu: |
| | 12 | {{{ |
| | 13 | #!sql |
| | 14 | SELECT pettype_id, species |
| | 15 | FROM pet_types |
| | 16 | ORDER BY species ASC; |
| | 17 | }}} |
| | 18 | 3. Owner selects "Dog", fills in the pet's name, age, and needs, and submits the form. |
| | 19 | 4. System creates the pet record in the database, linking it to the owner: |
| | 20 | {{{ |
| | 21 | #!sql |
| | 22 | INSERT INTO pets (name, photo, age, special_needs, description, owner_id, pettype_id) |
| | 23 | VALUES ( |
| | 24 | 'Sharka', |
| | 25 | 'sharka_photo.png', |
| | 26 | 4, |
| | 27 | 'Allergic to chicken', |
| | 28 | 'A very energetic mixed breed.', |
| | 29 | (SELECT user_id FROM users WHERE username = 'owner_bojan'), |
| | 30 | (SELECT pettype_id FROM pet_types WHERE species = 'Dog') |
| | 31 | ); |
| | 32 | }}} |