berntpopp / sysndd

GitHub Repository for the SysNDD database, web app and api used to curate gene disease relationships in neurodevelopmental disorders (NDD).
https://sysndd.dbmr.unibe.ch
MIT No Attribution
4 stars 0 forks source link

Feature request: Improve Data Storage by Using MySQL Database #104

Open berntpopp opened 1 month ago

berntpopp commented 1 month ago

Current Situation:

Problems:

Proposed Solution: Create new tables in the MySQL database to handle the following:

  1. Logging: Store log entries currently saved in local files.
  2. Pubtator API Requests: Cache responses to reduce external API calls.
  3. JSON Storage: Save and load JSON objects for dynamic content (HELP, FAQ, Startpage, etc.).

Database Table Design:

  1. Logging Table:

    CREATE TABLE `logging` (
     `id` INT AUTO_INCREMENT PRIMARY KEY,
     `timestamp` DATETIME NOT NULL,
     `address` VARCHAR(255) NOT NULL,
     `agent` TEXT,
     `host` VARCHAR(255),
     `request_method` VARCHAR(10),
     `path` TEXT,
     `query` TEXT,
     `post` TEXT,
     `status` INT,
     `duration` FLOAT,
     `file` VARCHAR(255),
     `modified` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    );
  2. Pubtator API Cache Table:

    CREATE TABLE `pubtator_cache` (
      `id` INT AUTO_INCREMENT PRIMARY KEY,
      `query` TEXT NOT NULL,
      `page` INT NOT NULL,
      `response` JSON NOT NULL,
      `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );
  3. JSON Storage Table:

      CREATE TABLE `json_storage` (
        `id` INT AUTO_INCREMENT PRIMARY KEY,
        `name` VARCHAR(255) NOT NULL,
        `json_data` JSON NOT NULL,
        `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
      );

Tables:

Pubtator API Cache Table:

Logging Table:

JSON Data Table:

Tasks:

Design Database Tables:

Expected Benefits:

berntpopp commented 1 month ago

relates to #57

berntpopp commented 1 month ago

relates to #48

berntpopp commented 1 month ago

Completed Tasks:

  1. Added Three New Scripts for Database Integration:

    • 15_Rcommands_sysndd_db_logging_table.R: Script to create and manage the logging table in MySQL.
    • 16_Rcommands_sysndd_db_pubtator_cache_table.R: Script to handle the PubTator cache table for efficient data retrieval and storage.
    • 17_Rcommands_sysndd_db_json_storage_table.R: Script for managing JSON storage tables in the MySQL database.
  2. Updated API Logging Functions:

    • Enhanced the API to log messages directly to the MySQL database.
    • Modified the start_sysndd_api.R script to include new logging functions and integrate with the MySQL database.