The Dealer
Power Member
Alguem me sabe dizer porque é que me dá erro a criar a tabela Notas mas se tirar a Foreign Key referente à tabela Disciplinas já dá? (Geoblast eu sei que os vários campos notas continua a não ser o mais eficiente, mas por agora terá de servir)
Código:
CREATE TABLE IF NOT EXISTS Disciplinas (
parent int(11) NOT NULL,
child int(11) NOT NULL auto_increment,
nome char(30),
tipo varchar(10) DEFAULT 'C',
semestre char(5) DEFAULT '-',
Ano int,
momentos int NOT NULL,
PRIMARY KEY (child,nome)
)AUTO_INCREMENT=11 ;
CREATE TABLE Notas(
ID_Notas int NOT NULL AUTO_INCREMENT,
n1 char(5) DEFAULT '-',
n2 char(5) DEFAULT '-',
n3 char(5) DEFAULT '-',
n4 char(5) DEFAULT '-',
n5 char(5) DEFAULT '-',
n6 char(5) DEFAULT '-',
n7 char(5) DEFAULT '-',
Exame1 char(5) DEFAULT '-',
Exame2 char(5) DEFAULT '-',
Exame3 char(5) DEFAULT '-',
NFinal char(5) DEFAULT '-',
Numero int NOT NULL,
nome char(30),
PRIMARY KEY(ID_Notas),
FOREIGN KEY(Numero) REFERENCES Alunos(Numero),
FOREIGN KEY(nome) REFERENCES Disciplinas(nome));