put iddossier as a foreign key in the file table (the right solution) or idfichier as a foreign key in the folder relationship?

22 Views Asked by At

For the design of a database I have a one-to-many relationship. It would be a folder to several files and a file belongs to a folder.

Which should I do and why--put iddossier as a foreign key in the file table (the right solution) or idfichier as a foreign key in the folder relationship?

CREATE TABLE dossier(
    nomDossier VARCHAR(60),
    iddossier integer,
    PRIMARY KEY(iddossier)
 );

 CREATE TABLE fichier(
    nomFichier VARCHAR(60),
    idfichier integer,
    dossierid integer,
    PRIMARY KEY(idfichier),
    CONSTRAINT fichier_fk FOREIGN KEY(dossierid) REFERENCES dossier(iddossier)
  );
0

There are 0 best solutions below