-- MySQL Script generated by MySQL Workbench
-- Wed 07 Jan 2026 03:49:23 PM EET
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema rssto
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema rssto
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `rssto` ;
USE `rssto` ;

-- -----------------------------------------------------
-- Table `rssto`.`channel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel` (
  `channel_id` INT NOT NULL AUTO_INCREMENT,
  `url` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`channel_id`),
  UNIQUE INDEX `url_UNIQUE` (`url` ASC) VISIBLE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`channel_item`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item` (
  `channel_item_id` INT NOT NULL AUTO_INCREMENT,
  `channel_id` INT NOT NULL,
  `pub_date` BIGINT NOT NULL,
  `link` VARCHAR(255) NOT NULL,
  `title` VARCHAR(255) NULL,
  `description` LONGTEXT NULL,
  PRIMARY KEY (`channel_item_id`),
  UNIQUE INDEX `url_UNIQUE` (`link` ASC) VISIBLE,
  INDEX `fk_channel_item_channel_idx` (`channel_id` ASC) VISIBLE,
  CONSTRAINT `fk_channel_item_channel`
    FOREIGN KEY (`channel_id`)
    REFERENCES `rssto`.`channel` (`channel_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`source`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`source` (
  `source_id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`source_id`),
  UNIQUE INDEX `name_UNIQUE` (`name` ASC) VISIBLE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rssto`.`content`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rssto`.`content` (
  `content_id` BIGINT NOT NULL AUTO_INCREMENT,
  `channel_item_id` INT NOT NULL,
  `source_id` INT NULL,
  `title` VARCHAR(255) NOT NULL,
  `description` LONGTEXT NOT NULL,
  PRIMARY KEY (`content_id`),
  INDEX `fk_content_channel_item_idx` (`channel_item_id` ASC) VISIBLE,
  INDEX `fk_content_source_idx` (`source_id` ASC) VISIBLE,
  UNIQUE INDEX `UNIQUE` (`channel_item_id` ASC, `source_id` ASC) VISIBLE,
  CONSTRAINT `fk_content_channel_item`
    FOREIGN KEY (`channel_item_id`)
    REFERENCES `rssto`.`channel_item` (`channel_item_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_content_source`
    FOREIGN KEY (`source_id`)
    REFERENCES `rssto`.`source` (`source_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
