Leudassdf Posted June 7, 2013 at 07:55 PM Report #511583 Posted June 7, 2013 at 07:55 PM (edited) Boas pessoal, Eu estou a tentar criar estas tabelas. no entanto quando é para criar a tabela respostas obtenho o erro:There are no primary or candidate keys in the referenced table("questoes"). Alguem sabe como resolver? Cumprimentos Create table Questoes( NQuestao decimal Primary key, CotacaoTotal decimal, Tipo varchar(20), Id_Teste int, FOREIGN KEY (Id_Teste) REFERENCES Teste(Id_Teste)); Create table Respostas( N_Processo varchar(10), Classificacao decimal, Tipo varchar(20), NQuestao decimal, FOREIGN KEY (NQuestao) REFERENCES teste(NQuestao), FOREIGN KEY (NQuestao) REFERENCES Questoes(NQuestao), FOREIGN KEY (N_Processo) REFERENCES Alunos(N_Processo)); Create table Teste( Id_Teste int identity(1,1) primary key, Descricao varchar(50), Tema_Modulo varchar(50), CotacaoTotal decimal, Data DATE DEFAULT GETDATE(), CodTruma int, N_Prof_Processo varchar(10), CodDisciplina int, FOREIGN KEY (N_Prof_Processo) REFERENCES Professor (N_Prof_Processo), FOREIGN KEY (CodTruma) REFERENCES Turma (CodTruma), FOREIGN KEY (CodDisciplina) REFERENCES Disciplina (CodDisciplina)); Edited June 7, 2013 at 09:16 PM by Leudassdf
nelsonr Posted June 7, 2013 at 08:37 PM Report #511591 Posted June 7, 2013 at 08:37 PM Estás a tentar executar isso nessa ordem? E o resto do script?
jsWizard Posted June 7, 2013 at 08:43 PM Report #511592 Posted June 7, 2013 at 08:43 PM quando executas isto: FOREIGN KEY (Id_Teste) REFERENCES Teste(Id_Teste)); a tabela Teste ainda não existe! deves criar primeiro as tabelas todas e só depois as FKs. 1 Report
Leudassdf Posted June 7, 2013 at 09:21 PM Author Report #511595 Posted June 7, 2013 at 09:21 PM a ordem aqui está incorreta. eço desculpa. mas efetivamente no meu script está aseguinte: teste,questoes e o depois as respostas
Leudassdf Posted June 7, 2013 at 09:36 PM Author Report #511599 Posted June 7, 2013 at 09:36 PM resolvido. ficou assim: Create table Questoes( NQuestao decimal , CotacaoTotal decimal, Tipo varchar(20), Id_Teste int, primary key(nquestao,id_teste), FOREIGN KEY (Id_Teste) REFERENCES Teste(Id_Teste)); Create table Respostas( N_Processo varchar(10), Classificacao decimal, Tipo varchar(20), id_teste int, NQuestao decimal, FOREIGN KEY (NQuestao,id_teste) REFERENCES Questoes(NQuestao,id_teste), FOREIGN KEY (N_Processo) REFERENCES Alunos(N_Processo)); 1 Report
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now