# dbMineHandler Documentation ## Overview This document describes the database relationships and interactions for the `dbMineHandler` class. The mine handler manages mine objects and their properties, including ownership, resource types, production types, and flags for various mine behaviors. ## Handler Class **File:** `src/engine/db/handlers/dbMineHandler.java` **Class:** `dbMineHandler` **Extends:** `dbHandlerBase` ## Database Tables ### Main Table - **Table Name:** `obj_mine` - **Description:** Stores mine-specific data including owner, resource type, production type, and flags - **Columns:** - UID (Primary Key) - mine_ownerUID - mine_resource - mine_type - flags ### Related Tables | Table Name | Description | Relationship | |------------|-------------|--------------| | `obj_building` | Base building data for mines | One-to-one with obj_mine via UID | | `object` | Generic object data including parent relationships | One-to-one with obj_mine via UID | ## Key Queries ### GET_MINE ```sql SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` WHERE `object`.`UID` = ? ``` **File:** `dbMineHandler.java`, Line ~25 ### GET_ALL_MINES_FOR_SERVER ```sql SELECT `obj_mine`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mine` ON `obj_mine`.`UID` = `object`.`UID` ``` **File:** `dbMineHandler.java`, Line ~43 ### CHANGE_OWNER ```sql UPDATE `obj_mine` SET `mine_ownerUID`=? WHERE `UID`=? ``` **File:** `dbMineHandler.java`, Line ~57 ### CHANGE_RESOURCE ```sql UPDATE `obj_mine` SET `mine_resource`=? WHERE `UID`=? ``` **File:** `dbMineHandler.java`, Line ~71 ### CHANGE_TYPE ```sql UPDATE `obj_mine` SET `mine_type`=? WHERE `UID`=? ``` **File:** `dbMineHandler.java`, Line ~85 ### SET_FLAGS ```sql UPDATE `obj_mine` SET `flags`=? WHERE `UID`=? ``` **File:** `dbMineHandler.java`, Line ~99 ## Relationships 1. **Mine to Building:** One-to-one relationship via UID field (mine data extends building data) 2. **Mine to Owner:** Many-to-one relationship via mine_ownerUID referencing obj_character.UID 3. **Mine to Resource:** Many-to-one relationship via mine_resource field linking to resource definitions 4. **Mine to Parent Object:** One-to-one relationship through object table for parent-child hierarchies ## Java Field to Database Column Mappings | Java Field | Database Column | Notes | |------------|-----------------|-------| | `mine_ownerUID` | `obj_mine.mine_ownerUID` | Character UID of the mine owner | | `mine_resource` | `obj_mine.mine_resource` | Resource type being mined | | `mine_type` | `obj_mine.mine_type` | Production type of the mine | | `flags` | `obj_mine.flags` | Bit flags for mine properties | | `UID` | `obj_mine.UID` | Unique identifier for the mine object |