Nunca he "codificado a mano" el código de creación de objetos para SQL Server y la declinación de la clave externa es aparentemente diferente entre SQL Server y Postgres. Aquí está mi sql hasta ahora:
drop table exams;
drop table question_bank;
drop table anwser_bank;
create table exams
(
exam_id uniqueidentifier primary key,
exam_name varchar(50),
);
create table question_bank
(
question_id uniqueidentifier primary key,
question_exam_id uniqueidentifier not null,
question_text varchar(1024) not null,
question_point_value decimal,
constraint question_exam_id foreign key references exams(exam_id)
);
create table anwser_bank
(
anwser_id uniqueidentifier primary key,
anwser_question_id uniqueidentifier,
anwser_text varchar(1024),
anwser_is_correct bit
);
Cuando ejecuto la consulta me sale este error:
Mensaje 8139, Nivel 16, Estado 0, Línea 9 El número de columnas de referencia en clave externa difiere del número de columnas referenciadas, tabla 'question_bank'.
¿Puedes detectar el error?
fuente