-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswimstats.sql
More file actions
61 lines (52 loc) · 2.05 KB
/
Copy pathswimstats.sql
File metadata and controls
61 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Snowflake */
CREATE TABLE IF NOT EXISTS swimstats.club (
club_num_id SERIAL PRIMARY KEY,
club_name domaine.nom NOT NULL
);
CREATE TABLE IF NOT EXISTS swimstats.style (
style_num_id SERIAL PRIMARY KEY,
style_name domaine.nom NOT NULL
);
CREATE TABLE IF NOT EXISTS swimstats.distance (
distance_num_id SERIAL PRIMARY KEY,
distance_metre domaine.metre NOT NULL
);
CREATE TABLE IF NOT EXISTS swimstats.sex (
sex_code domaine.code PRIMARY KEY,
sex_name domaine.nom NOT NULL
);
CREATE TABLE IF NOT EXISTS swimstats.country (
country_code domaine.code PRIMARY KEY,
country_name domaine.nom NOT NULL
);
/* Star */
CREATE TABLE IF NOT EXISTS swimstats.place (
place_num_id SERIAL PRIMARY KEY,
city_name domaine.nom NOT NULL,
country_code domaine.nom NOT NULL REFERENCES swimstats.country(country_code)
);
CREATE TABLE IF NOT EXISTS swimstats.race (
race_num_id SERIAL PRIMARY KEY,
distance_num_id INT NOT NULL REFERENCES swimstats.distance(distance_num_id),
style_num_id INT NOT NULL REFERENCES swimstats.style(style_num_id)
);
CREATE TABLE IF NOT EXISTS swimstats.swimmer (
swimmer_num_id domaine.num_id PRIMARY KEY,
swimmer_firstname domaine.prenom NOT NULL,
swimmer_lastname domaine.nom NOT NULL,
birth_year domaine.annee NOT NULL,
club_num_id domaine.num_id NOT NULL REFERENCES swimstats.club(club_num_id),
sex_code domaine.code NOT NULL REFERENCES swimstats.sex(sex_code),
nationality_code domaine.code NOT NULL REFERENCES swimstats.nationality(nationality_code)
);
/* Fact */
CREATE TABLE IF NOT EXISTS swimstats.result (
result_num_id SERIAL PRIMARY KEY,
swimmer_num_id domaine.num_id NOT NULL REFERENCES swimstats.swimmer(swimmer_num_id),
race_num_id domaine.num_id NOT NULL REFERENCES swimstats.race(race_num_id),
place_num_id domaine.num_id NOT NULL REFERENCES swimstats.place(place_num_id),
pool_metre domaine.metre NOT NULL,
race_date domaine.debut_date NOT NULL,
time_millisecond domaine.duree_seconde NOT NULL,
race_points domaine.cote NOT NULL
);