· 6 years ago · Jun 03, 2019, 12:32 PM
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
37create table masterclass(
38id int auto_increment,
39datum date,
40begintijd int,
41eindtijd int,
42kosten int,
43minimale_rating int,
44maximaal_aantal_spelers int,
45locatie int,
46gecontracteerde_speler int,
47primary key (id),
48foreign key (locatie) references locatie(id),
49foreign key (gecontracteerde_speler) references speler(id));
50
51create table inschrijvingmasterclass(
52masterclass int,
53speler int,
54betaald enum('j', 'n'),
55primary key (masterclass, speler),
56foreign key (masterclass) references masterclass(id),
57foreign key (speler) references speler(id));
58
59create table inschrijvingtoernooi(
60toernooi int,
61speler int,
62betaald enum('j', 'n'),
63primary key (toernooi, speler),
64foreign key (toernooi) references toernooi(id),
65foreign key (speler) references speler(id));
66
67
68create table tafel(
69tafel int,
70ronde int,
71toernooi int,
72speler int,
73plek int,
74primary key(tafel, ronde, toernooi, speler),
75foreign key(toernooi, speler) references inschrijvingtoernooi(toernooi, speler));