I'm getting this error while trying to create a table
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null, PRIMARY KEY(nomeA), FOREIGN KEY(nomeA) REFERENCES Alimento(nomeA))' at line 4
and here's the code
create table Alimento
(nomeA varchar(255) not null unique,
vegetariano tinyint(1) not null,
PRIMARY KEY(nomeA));
create table Simples
(nomeA varchar(255) not null,
calgramas numeric(5,2) not null,
tipo varchar not null,
PRIMARY KEY(nomeA),
FOREIGN KEY(nomeA) REFERENCES Alimento(nomeA));
create table Agregado
(nomeA varchar(255) not null,
calorias numeric(5,2) not null,
PRIMARY KEY(nomeA),
FOREIGN KEY(nomeA) REFERENCES Alimento(nomeA));
You forgot the length of your tipo
column
tipo varchar(100) not null
^^^^^---------------add something like this
If you use a SQL Tool like Mysql Workbench then such errors will be highlighted and are easy to find.