· 6 years ago · Jun 04, 2019, 09:04 AM
1drop database if exists fullhouse;
2create database if not exists fullhouse;
3use fullhouse;
4
5create table speler(
6id int auto_increment,
7naam varchar(50),
8adres varchar(50),
9telefoonnummer varchar(50),
10email varchar(50),
11postcode varchar(8),
12woonplaats varchar(25),
13geboortedatum date,
14geslacht enum('M', 'V'),
15rating int default 0,
16contract enum('J', 'N'),
17primary key (id));
18
19create table locatie(
20id int auto_increment,
21plaats varchar(25),
22primary key (id));
23
24create table toernooi(
25id int auto_increment,
26datum date,
27begintijd int,
28eindtijd int,
29thema varchar(50),
30maximaal_aantal_spelers int,
31inleggeld int,
32uiterste_inschrijfdatum date,
33locatie int,
34primary key (id),
35foreign key (locatie) references locatie(id));
36
37
38create table masterclass(
39id int auto_increment,
40datum date,
41begintijd int,
42eindtijd int,
43kosten int,
44minimale_rating int,
45maximaal_aantal_spelers int,
46locatie int,
47gecontracteerde_speler int,
48primary key (id),
49foreign key (locatie) references locatie(id),
50foreign key (gecontracteerde_speler) references speler(id));
51
52create table inschrijvingmasterclass(
53masterclass int,
54speler int,
55betaald enum('j', 'n'),
56primary key (masterclass, speler),
57foreign key (masterclass) references masterclass(id),
58foreign key (speler) references speler(id));
59
60create table inschrijvingtoernooi(
61toernooi int,
62speler int,
63betaald enum('j', 'n'),
64primary key (toernooi, speler),
65foreign key (toernooi) references toernooi(id),
66foreign key (speler) references speler(id));
67
68
69create table conditie(
70id int not null auto_increment,
71voorwaarde varchar(50),
72primary key (id));
73
74create table toernooivoorwaarde(
75voorwaarde int,
76toernooi int,
77primary key (voorwaarde, toernooi),
78foreign key (toernooi) references toernooi(id),
79foreign key (voorwaarde) references conditie(id)
80);
81
82create table tafel(
83tafel int,
84ronde int,
85toernooi int,
86speler int,
87plek int,
88primary key(tafel, ronde, toernooi, speler),
89foreign key(toernooi, speler) references inschrijvingtoernooi(toernooi, speler));