Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Duda base de datos MySql

estoy tratando de descifrar como armar esta base datos, tengo la siguiente informació pero tengo dudas de donde colocar las claves foraneas ya que el esquema no está tan claro, agradeceria si me pudiesen dar una mano. Sobre todo en la relacion "one or many to one or many" con pregunta y etiqueta, un saludo.

enter image description here

/*Creación de la base de datos y seteado para utilizar*/
create database preguntas_respuestas;
use preguntas_respuestas;

/*Creación de las tablas*/
create table Categoria(
    IDCategoria int not null primary key auto_increment,
    nombre varchar(30) default null
);

create table Pregunta(
    IDPregunta int not null primary key auto_increment,
    descripcion varchar(250) default null,
    fechaPublicacion date default null, /*YYYY-MM-DD,*/
    FKCategoria int not null,
    foreign key(FKCategoria) references Categoria(IDCategoria)
);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Deberías diseñar una tabla intermedia para romper las cardinalidad de muchos a muchos. Es decir, una tabla que sea pregunta_etiqueta que tenga como PK ID_PREGUNTA y ID_ETIQUETA y foreign key a la tabla pregunta y etiqueta.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading