Exercise 15: Botanical Garden
On this page
erDiagram
plant {
string name
string species
string origin
int key PK "id_plant"
int id_plant_state FK "id_plant_state"
}
plant_state {
string name
string label
string uuid
int key PK "id_plant_state"
}
gardener {
string name
string specialization
int key PK "id_gardener"
}
section {
string name
string description
int key PK "id_section"
int id_gardener FK "id_gardener"
}
section_plant {
int key PK "id_section_plant"
int id_section FK "id_section"
int id_plant FK "id_plant"
}
plant_state one--many plant : has
plant one--many section_plant : grows_in
section one--many section_plant : contains
gardener one--many section : tends
Description
The property “name” in the table “plant_state” can have the values: “Healthy”, “Diseased”, “Removed”.
This app manages a garden by tracking plants, their growth states, sections, and gardeners. It links plants to sections where they grow, associates each plant with a growth state, and assigns gardeners to specific sections they tend. It helps organize plant care and garden management efficiently.
In entity “plant_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
plant/gardener/section/plant_state/section_plant: Add, Edit, Update, Delete.
- When a plant is created, it will automatically become “Healthy”.
- The field “Plant state” from entity “plant” will be read-only in edit view.
Create a catalog for entities: “gardener”, “section”, “plant” and “plant_state”.
Create event listeners for tables that needs validations (e.g., adding a plant without a name, section without description, etc., should not be allowed).
In section, calculate the total number of plants.
Add a new entity action at the section level “Remove section”:
- It will change the state of all plants in the section to “Removed”;
- A section cannot be removed if it contains any “Healthy” plants → warning message.
- A section cannot be removed if it already in the “Removed” state → warning message.
Plant report: section situation at plant level (total number of sections, plant details).
Gardener report: section situation at gardener level (total number of sections, plant details).