Problem in creating foreign keys MySQL

0

I'm trying to implement a 1: 1 relationship between the Official table and the User table in the MySQL Workbench, but in generating the Diagram I see that the relationship always stays in 1: n, even with the UNIQUE constraint on the foreign key.

CREATE TABLE 'funcionario' (
  'id' int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  'nome' varchar(50) NOT NULL,
  'cpf' varchar(50) NOT NULL UNIQUE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE 'usuario' (
  'id' int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  'nome' varchar(50) NOT NULL UNIQUE,
  'senha' varchar(8) NOT NULL,
  'nivel' enum('1','2','3') NOT NULL,
  'datacadastro' DATE NOT NULL,
  'id_funcionario' int(11) NOT NULL UNIQUE,
  INDEX 'fk_id_funcionario' ('id_funcionario' ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

alter table 'usuario'
add foreign key ('id_funcionario') references 'funcionario'('id');

How can I specify that, in this case, the relationship should be 1: 1?

    
asked by anonymous 22.07.2018 / 19:32

0 answers