Exercise 12: Wildlife Conservation

erDiagram

    species {
        string name
        string habitat
        string status
        int key PK "id_species"
    }

    ranger {
        string name
        string contact
        int key PK "id_ranger"
    }

    sighting {
        datetime date
        string location
        string notes
        int key PK "id_sighting"
        int id_sighting_state FK "id_sighting_state"
        int id_ranger FK "id_ranger"
    }

    sighting_state {
        string name
        string label
        string uuid
        int key PK "id_sighting_state"
    }

    species_sighting {
        int key PK "id_species_sighting"
        int id_species FK "id_species"
        int id_sighting FK "id_sighting"
    }

    sighting_state one--many sighting : has
    species one--many species_sighting : observed_in
    ranger one--many sighting : reports
    sighting one--many species_sighting : records

Description

  • The property “name” in the table “sighting_state” can have the values: “Pending”, “Ongoing”, “Confirmed”, “Discarded”.

  • This app helps track wildlife sightings reported by rangers. Rangers log sightings of species, including details like date, location, and status.

  • It links sightings to species and keeps track of their confirmation state (e.g., confirmed, discarding). It helps manage species data, sightings, and the rangers involved in reporting them.

  • In entity “sighting_state”, name represents the state that will be displayed on the screen, label represents the value that programmer will use to filter the states, and the uuid represents a value to distinguish the states.

  • OBS: The value of the field “uuid” is generated automatically.

Tasks

  • species/ranger/sighting/sighting_state/species_sighting: Add, Edit, Delete.

    • When the sighting is created, it will automatically become “Pending”.

    • The field “Sighting state” from entity “sighting” will be read-only in edit view.

  • Create a catalog for entities: “sighting_state”, “sighting”, “species” and “ranger”.

  • Create event listeners for tables that needs validations (e.g., adding a species without a name, sighting without location, etc., should not be allowed).

  • Check if the sighting is available by date. If it is not → validation message.

  • Add a new entity action at the sighting level “Discard sighting”:

    • It will change the sighting state to “Discarded”;
    • A sighting cannot be discarded if it is in the “Confirmed” or “Ongoing” state → validation message;
    • First check if the sighting has already been discarded (it has the status “Discarded”), if it has → validation message.
  • Add a new entity action at the species level “Initiate sighting”:

    • Ensure that each sighting is associated with at least one species, if it is not → validation message;
    • First check if the sighting is already in the “Ongoing” state (it was already initiated), if it is → validation message;
    • After the initiation of the sighting, the state will change from “Pending” → “Ongoing”;
    • A sighting cannot be initiated if it is in the “Completed” or “Discarded” state, if it has → validation message.
  • Add a new entity action at the sighting level “Confirm sighting”:

    • It can’t be confirmed if it is “Pending” → validation message;
    • It can’t be confirmed if it is “Discarded” → validation message;
    • If it is already in “Confirmed” state → validation message.
  • Sighting report: species situation at sighting level (total number of species observed).

  • Species report: sighting situation at species level (total number of sightings, location details).

  • Ranger report: sighting situation at ranger level (total number of sightings, location details).