How to make a H2 DB with foreign key

29 Views Asked by At

I need to make a H2 DB from this diagram made on Workbench. I'm having problem with foreign key. I'm learning MySQL. (https://i.stack.imgur.com/z2Mbm.jpg)

The first table is working but the second syntax is not. Says that can't find turmas table.

create table Turmas (
"id_turmas" identity PRIMARY KEY,
"nome" varchar(50),
"periodo" VARCHAR(10) 
);

CREATE TABLE "Provas" (
    "id_provas" SERIAL PRIMARY KEY,
    "nome" VARCHAR(15) NULL,
    "data" VARCHAR(45) NULL,
    "Turmas_id_turmas" INT,

    CONSTRAINT "fk_Provas_Turmas1" 
    FOREIGN KEY ("Turmas_id_turmas") 
    REFERENCES "Turmas" ("id_turmas")
);
0

There are 0 best solutions below