CREATE TABLE speler
(
scode INT(5) NOT NULL AUTO_INCREMENT,
naam CHAR(20) NOT NULL,
adres CHAR(50) ,
postcode CHAR(6) ,
woonplaats CHAR(15) ,
tel_num INT(11) NOT NULL,
email CHAR(40) NOT NULL,
bekende_speler CHAR(3) NOT NULL,
rating INT(3) NOT NULL,
gewonnen_inleggeld VARCHAR(20) ,
PRIMARY KEY (scode)
) ENGINE=InnoDB;
CREATE TABLE locatie (
lcode INT(5) NOT NULL AUTO_INCREMENT,
locatie VARCHAR(55) NOT NULL,
PRIMARY KEY (lcode)) ENGINE=InnoDB;
CREATE TABLE toernooi (
tcode INT(5) NOT NULL AUTO_INCREMENT,
type_spel VARCHAR(50) NOT NULL,
aantal_tafels INT(5) NOT NULL,
aantal_rondes INT(5) NOT NULL,
aantal_spelers INT(5) NOT NULL,
max_spelers INT(5) NOT NULL,
datum DATE NOT NULL,
tijd VARCHAR(11) NOT NULL,
inleg_geld VARCHAR(21),
lcode INT(5) NOT NULL,
PRIMARY KEY (tcode),
FOREIGN KEY (lcode) REFERENCES locatie(lcode)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE ronde (
rcode INT(5) NOT NULL AUTO_INCREMENT,
tcode INT(5) NOT NULL,
PRIMARY KEY (rcode),
FOREIGN KEY (tcode) REFERENCES toernooi(tcode)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE tafel (
tafelnr INT(5) NOT NULL AUTO_INCREMENT,
aantal_fiches VARCHAR(255),
aantal_spelers INT(5) ,
max_spelers INT(5) NOT NULL,
rcode INT(5) NOT NULL,
PRIMARY KEY (tafelnr),
FOREIGN KEY(rcode) REFERENCES ronde(rcode)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE masterclass
(
mcode INT(5) NOT NULL AUTO_INCREMENT,
kosten VARCHAR(20) NOT NULL,
max_spelers INT(3) NOT NULL,
min_rating INT(3) NOT NULL,
scode INT(5) NOT NULL,
lcode INT(5) NOT NULL,
PRIMARY KEY(mcode),
FOREIGN KEY(scode) REFERENCES speler(scode)
ON DELETE RESTRICT
ON UPDATE CASCADE,
FOREIGN KEY(lcode) REFERENCES locatie(lcode)
ON DELETE RESTRICT
ON UPDATE CASCADE
)ENGINE=InnoDB;
CREATE TABLE inschrijving_masterclass
(
scode INT(5) NOT NULL,
mcode INT(5) NOT NULL,
betaald CHAR(3) NOT NULL,
PRIMARY KEY(scode, mcode),
FOREIGN KEY(scode) REFERENCES speler(scode)
ON DELETE RESTRICT
ON UPDATE CASCADE,
FOREIGN KEY (mcode) REFERENCES masterclass(mcode)
ON DELETE RESTRICT
ON UPDATE CASCADE
)ENGINE=InnoDB;
CREATE TABLE inschrijving_toernooi
(
scode INT(5) NOT NULL,
tcode INT(5) NOT NULL,
Betaald INT(3) NOT NULL,
PRIMARY KEY(scode, tcode),
FOREIGN KEY(scode) REFERENCES speler(scode)
ON DELETE RESTRICT
ON UPDATE CASCADE,
FOREIGN KEY(tcode) REFERENCES toernooi(tcode)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE ingeschreven_aan (
scode INT(5) NOT NULL,
tcode INT(5) NOT NULL,
tafelnr INT(5) NOT NULL,
PRIMARY KEY(scode, tcode, tafelnr),
FOREIGN KEY (scode) REFERENCES speler(scode)
ON DELETE SET NULL
ON UPDATE CASCADE,
FOREIGN KEY (tcode) REFERENCES toernooi(tcode)
ON DELETE RESTRICT
ON UPDATE CASCADE,
FOREIGN KEY (tafelnr) REFERENCES tafel(tafelnr)
ON DELETE SET NULL
ON UPDATE CASCADE
) ENGINE=InnoDB;
问问题
49 次