Referenced table not found in the data dictionary mariadb

Viewed 153

so I have written this Mariadb code as the solution for an assignment and am running it on HeidiSQL. It should work in theory however I am getting the error message SQL Error (1005): Can't create table bestellung.arbeitetin (errno: 150 "Foreign key constraint is incorrectly formed"). Upon using show warning, the program elaborates that "referenced table bestellung.arbeitetin not found in the data dictionary". I am wondering, is there something wrong with the code?

Datum date not NULL,
Abholtermin DATE,
Kostenstelle int not NULL,
Abteilung char(5) not NULL,
Mitarbeiter int not NULL,
Telefon int not NULL,
primary key (Bestellnummer)
);

create table enthaelt (
FK_Bestellnummer int not NULL,
FK_Artikelnummer char(10) not NULL,
Menge int not NULL,
unique key (FK_Bestellnummer, FK_Artikelnummer)
);

alter table enthaelt ADD
constraint FK_ArtikelNr
foreign key (FK_Artikelnummer)
references Artikel (Artikelnummer);

alter table enthaelt ADD
constraint FK_BestellNr
foreign key (FK_Bestellnummer)
references Bestellung (Bestellnummer);

create table arbeitetin
(
FK_PersNr int not NULL,
FK_ProjektNr int not NULL,
unique key(FK_PersNr, FK_ProjektNr)
);

alter table arbeitetin ADD 
    constraint FK_ARBEITETIN_MITARBEITER1 
        FOREIGN KEY (FK_PersNr) 
            REFERENCES Mitarbeiter (PersNr);

alter table arbeitetin ADD
    constraint FK_ARBEITETIN_PROJEKT
        foreign key (FK_ProjektNr)
            references Projekt (ProjektNr);

alter table Mitarbeiter ADD
    constraint FK_MITARBEITER_ABTEILUNG
        foreign key (FK_Abkuerzung)
            references Abteilung (Abkuerzung); ``` 
0 Answers
Related