diff --git a/docs/erd.md b/docs/erd.md new file mode 100644 index 0000000..86befc7 --- /dev/null +++ b/docs/erd.md @@ -0,0 +1,105 @@ +```mermaid +erDiagram + 🌱Plant ||--o{ ↔️PlantGroup : "belongs to" + 🪴Group ||--o{ ↔️PlantGroup : "contains" + + 🌱Plant }o--|| 🧬PlantSpecies : "is of" + + 🫳Action ||--o{ 📒ActionLog : "logged in" + 🌱Plant ||--o{ 📒ActionLog : "" + 🪴Group ||--o{ 📒ActionLog : "" + 📋MaintenancePlan ||--o{ 📒ActionLog : "logged in" + + 📋MaintenancePlan ||--o{ 🗓️MaintenancePlanAction : "has" + 🫳Action ||--o{ 🗓️MaintenancePlanAction : includes + + 🔧Tool ||--o{ ⚙️ToolAction : "" + 🫳Action ||--o{ ⚙️ToolAction : "" + + 🔧Tool ||--o{ 💾ToolAttributeValue : "has attribute with value" + 🏷️ToolAttribute ||--o{ 💾ToolAttributeValue : "has value" + + %% Entities + 🌱Plant { + int id + int species_id + string name + datetime date_acquired + } + + 🧬PlantSpecies { + int id + string name + string genus + string species + string cultivar + string variety + string authority + } + + 🪴Group { + int id + string name + } + + ↔️PlantGroup { + int id + int group_id + int plant_id + } + + 🫳Action { + int id + string name + string description + } + + 📒ActionLog { + int id + int action_id + int plant_id + int group_id + int plan_id + string notes + } + + 📋MaintenancePlan { + int id + int plant_id + int group_id + int maintenance_plan_action_id + } + + 🗓️MaintenancePlanAction { + int id + int maintenance_plan_id + int action_id + string schedule + } + + 🔧Tool { + int id + string name + string description + } + + ⚙️ToolAction { + int id + int tool_id + int action_id + } + + 🏷️ToolAttribute { + int id + string name + string description + } + + 💾ToolAttributeValue { + int id + int tool_attribute_id + int tool_id + string value_string + float value_number + } +``` \ No newline at end of file diff --git a/docs/schema-table.md b/docs/schema-table.md new file mode 100644 index 0000000..9fe62b9 --- /dev/null +++ b/docs/schema-table.md @@ -0,0 +1,141 @@ +## Entities +### `Plant` +Represents an **individual plant**. Contains instance-specific information and references a shared plant species. + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 15 | +| `species_id` | `int` | NO | FK to [PlantSpecies](#plantspecies) | 1 | +| `name` | `string` | YES | Given/nickname for the plant | "Big Fatty" | +| `date_acquired` | `datetime` | YES | Date acquired | 2025-08-14T14:30:45Z | + +--- + +### `PlantSpecies` +Represents **species-level data**. Shared, mostly static characteristics for plants of the same type. + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 1 | +| `name` | `string` | NO | Common name | Sunflower | +| `genus` | `string` | NO | Genus | *Helianthus* | +| `species` | `string` | NO | Species | *annuus* | +| `cultivar` | `string` | YES | Cultivar | | +| `variety` | `string` | YES | Variety | | +| `authority` | `string` | YES | Authority name | L. | + +--- + +### `Group` +Logical grouping of plants (e.g., location, category). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 3 | +| `name` | `string` | NO | Group name | "Location: Plant Cart" | + +--- + +### `PlantGroup` +**Junction table** implementing a many-to-many relationship between [Plant](#plant) and [Group](#group). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 1 | +| `group_id` | `int` | NO | FK to [Group](#group) | 3 | +| `plant_id` | `int` | NO | FK to [Plant](#plant) | 15 | + +--- + +### `Action` +An **action** is a type of care or maintenance performed on a plant (e.g., watering, fertilizing, pruning). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 4 | +| `name` | `string` | NO | Action name | Water | +| `description` | `string` | YES | Action description | "Give the plant some water" | + +--- + +### `ActionLog` +Records **which actions** were performed on **which plants or groups**. + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 22 | +| `action_id` | `int` | NO | FK to [Action](#action) | 4 | +| `plant_id` | `int` | YES | FK to [Plant](#plant) | NULL | +| `group_id` | `int` | YES | FK to [Group](#group) | 3 | +| `plan_id` | `int` | YES | FK to [MaintenancePlan](#maintenanceplan) | NULL | +| `notes` | `string` | YES | Notes on the action performed | "Dumped 500 gallons of electrolytes" | + +--- + +### `MaintenancePlan` +Defines a **recurring set of actions** to be applied to a plant or group (e.g., “Water every 15 days”). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 7 | +| `plant_id` | `int` | YES | FK to [Plant](#plant) | NULL | +| `group_id` | `int` | YES | FK to [Group](#group) | 3 | +| `maintenance_plan_action_id` | `int` | NO | FK to [MaintenancePlanAction](#maintenanceplanaction) | 11 | + +--- + +### `MaintenancePlanAction` +Links a [MaintenancePlan](#maintenanceplan) to the [Action](#action) to perform and specifies a schedule. + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 11 | +| `maintenance_plan_id` | `int` | NO | FK to [MaintenancePlan](#maintenanceplan) | 7 | +| `action_id` | `int` | NO | FK to [Action](#action) | 4 | +| `schedule` | `string` | NO | Execution interval (CRON format) | `0 0 */2 * *` | + +--- + +### `Tool` +Represents a **tool** used to complete an action (e.g., “warm water” for a watering action). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 5 | +| `name` | `string` | NO | Tool name | Warm Water | +| `description` | `string` | YES | Tool description | "Like bath water" | + +--- + +### `ToolAction` +**Junction table** implementing a many-to-many relationship between [Tool](#tool) and [Action](#action). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 2 | +| `tool_id` | `int` | NO | FK to [Tool](#tool) | 5 | +| `action_id` | `int` | NO | FK to [Action](#action) | 4 | + +--- + +### `ToolAttribute` +Defines a **custom attribute** of a tool (e.g., “pH”, “temperature”). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 8 | +| `name` | `string` | NO | Attribute name | Acidity | +| `description` | `string` | YES | Description of attribute | "Water acidity, measured in pH" | + +--- + +### `ToolAttributeValue` +Stores the value of a specific [ToolAttribute](#toolattribute) for a given [Tool](#tool). + +| Attribute | Type | Nullable | Description | Example | +| - | - | - | - | - | +| `id` | `int` | NO | Primary key | 14 | +| `tool_attribute_id` | `int` | NO | FK to [ToolAttribute](#toolattribute) | 8 | +| `tool_id` | `int` | NO | FK to [Tool](#tool) | 5 | +| `value_string` | `string` | YES | Text value | "Slightly acidic" | +| `value_number` | `float` | YES | Numeric value | 7.0 | diff --git a/schema.md b/schema.md deleted file mode 100644 index 3badbb5..0000000 --- a/schema.md +++ /dev/null @@ -1,69 +0,0 @@ -# Plant-man overview - -## Class: `Plant` -This class represents the plant to be managed, the fundamental object of our interest around which all of this software revolves. Contains instance-specific info. - -| Attribute | Type | Description | Example | -|-|-|-|-| -| `id` | `int` | Primary key | 15 | -| `plant_id` | `int` | Foreign Key | 0 | -| `name` | `string` | Given name | "Big Fatty" | -| `date_acquired` | `datetime` | Date acquired | 2025-08-14T14:30:45.0000000 - ---- - -## Class: `Plant Specification` -Contains mostly static info about the *species*, which every plant of this type shares - -| Attribute | Type | Description | Example | -|-|-|-|-| -| `id` | `int` | Primary key | 0 | -| `name` | `string` | Common Name | Sunflower | -| `genus` | `string` | Genus | *Helianthus* | -| `species` | `string` | Species | *annus* | -| `cultivar` | `string` | Cultivar | | -| `variety` | `string` | Variety | | -| `authority` | `string` | Authority | L. | - -## Class: `Group` -This is generic way to logically 'group' plants. - -| Attribute | Type | Description | Example | -|-|-|-|-| -| `id` | `int` | Primary Key | 0 | -| `name` | `string` | Given name | Location: Plant cart | - ---- - -## Class: `Plant-Group Relationship` -Records plant group membership. A plant may belong to many groups, and groups may contain many plants. - -| Attribute | Type | Description | Example | -|-|-|-|-| -| `id` | `int` | Primary key | 0 | -| `group_id` | `int` | Group ID (fk) | 0 | -| `plant_id` | `int` | Plant ID (fk)| 15 | - ---- - -## Class: `Action` -An action is work performed on a plant, e.g. watering, fertilizing, pruning, etc. - -| Attribute | Type | Description | Example | -|-|-|-|-| -| `id` | `int` | Primary key | 0 | -| `name` | `string` | Name of the Action | Water | -| `description` | `string` | Describe the action | give the plant some water! | - - -## Class: `Action Log` -Record which actions were performed on which plant or plant group - -| Attribute | Type | Description | Example | -|-|-|-|-| -| `id` | `int` | Primary key | 0 | -| `action_id` | `int` | Action ID (fk) | 0 | -| `plant_id` | `int` | Plant ID (fk) | null | -| `group_id` | `int` | Group ID (fk) | 0 | -| `notes` | `string` | Notes | Dumped 500 gallons of electrolytes on it | -