Well morning everybody,
so actually i have to do some work for my coming classtest, everything is working fine … just the last part of my sql script.
CREATE DATABASE IF NOT EXISTS db_schueler;
USE db_schueler;
CREATE TABLE IF NOT EXISTS tbl_schueler (
id INT(4) NOT NULL AUTO_INCREMENT,
name CHAR(12) NOT NULL,
vorname CHAR(12) NOT NULL,
adresse char(50) NOT NULL,
stadt CHAR(20) NOT NULL,
versetzung12 BIT NOT NULL, -- 1/0 bzw. Ja/Nein
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS tbl_fach (
fach_id INT(4) NOT NULL AUTO_INCREMENT,
tbl_schueler_id INT(4),
deutsch CHAR(12) NOT NULL,
mathe CHAR(12) NOT NULL,
englisch CHAR(12) NOT NULL,
datenbank CHAR(12) NOT NULL,
programmiertechnik CHAR(12) NOT NULL,
betriebnetzwerke CHAR(12) NOT NULL,
PRIMARY KEY (fach_id),
FOREIGN KEY (tbl_schueler_id) REFERENCES tbl_schueler(id)
);
CREATE TABLE IF NOT EXISTS tbl_zensuren (
zensuren_id INT(4) NOT NULL AUTO_INCREMENT,
schueler_versetzung12 BIT NOT NULL, -- 1/0 bzw. Ja/Nein
prüfung BIT NOT NULL, -- 1/0 bzw. Ja/Nein
PRIMARY KEY(zensuren_id),
FOREIGN KEY(schueler_versetzung12) REFERENCES tbl_schueler(versetzung12)
);
I am getting this Error Cant Create table ‘db.schueler.tbl_zensuren’ (erno: 150)
I Found out that this error stays in connection with the foreign key, but i have no idea.
I Hope s.o can help me to fix this.
Grettings