Buenas,
¿Podéis opinar sobre este diseño? está bien así, o creéis conveniente que le agregue una tabla más que relacione (tema, categoría y enlace)?
Código:
-- -----------------------------------------------------
-- Table `codelab`.`categorias`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `codelab`.`categorias` (
`idcategorias` SMALLINT NOT NULL AUTO_INCREMENT ,
`nombre` VARCHAR(45) NOT NULL ,
`ruta` TEXT NULL ,
PRIMARY KEY (`idcategorias`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `codelab`.`temas`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `codelab`.`temas` (
`idtemas` INT NOT NULL AUTO_INCREMENT ,
`idcategorias` SMALLINT NOT NULL ,
`titulo` VARCHAR(100) NOT NULL ,
`ruta` TEXT NULL ,
`comentario` TEXT NULL ,
`enlaces` TEXT NULL ,
PRIMARY KEY (`idtemas`) ,
INDEX `fk_temas_categorias` (`idcategorias` ASC) ,
CONSTRAINT `fk_temas_categorias`
FOREIGN KEY (`idcategorias` )
REFERENCES `codelab`.`categorias` (`idcategorias` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `codelab`.`enlaces`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `codelab`.`enlaces` (
`idenlaces` INT NOT NULL AUTO_INCREMENT ,
`idtemas` INT NOT NULL ,
`nombre` VARCHAR(100) NULL ,
`ruta` TEXT NULL ,
PRIMARY KEY (`idenlaces`) ,
INDEX `fk_enlaces_temas1` (`idtemas` ASC) ,
CONSTRAINT `fk_enlaces_temas1`
FOREIGN KEY (`idtemas` )
REFERENCES `codelab`.`temas` (`idtemas` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
El objetivo es muy sencillito, quiero poder hacer un buscador de temas, que al pulsar sobre la categoria PHP y me muestren todos los temas que tengan la categoria PHP.
O bien, buscar por un titulo de tema, ej. "formulario" y me muestre los temas que coincidan por su titulo.
Y también me interesaría que si el tema tiene enlaces hacía otros temas o hacia fuera, estos quedasen reflejados en el propio tema.
Muchas gracias de antemano!