-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.ddl
72 lines (66 loc) · 1.78 KB
/
schema.ddl
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
62
63
64
65
66
67
68
69
70
71
72
drop schema if exists NYCCrash cascade;
create schema NYCCrash;
set search_path to NYCCrash;
-- An accident that occured in New York City
create table NYCAccidents(
collisionID varchar(10) primary key,
crashTime timestamp,
longitude float,
latitude float
);
-- A weather station and its location in coordinates.
create table NYCWeatherStations(
stationID varchar(11) primary key,
longitude float,
latitude float,
unique (longitude, latitude)
);
-- Daily weather details from weather stations.
create table NYCDailyWeather(
day date not null,
stationID varchar(11) not null,
minTemp float,
maxTemp float,
avgTemp float,
precip float,
snowFall float,
snowDepth float,
waterSnowOnGround float,
waterSnowfall float,
avgWindSpeed float,
primary key (day, stationID),
foreign key (stationID) references NYCWeatherStations
);
-- Accident involving at least one injury or death.
create table NYCCasualties(
collisionID varchar(10) primary key,
pedestrianInjured integer,
pedestrianKilled integer,
cyclistInjured integer,
cyclistKilled integer,
motoristInjured integer,
motoristKilled integer,
foreign key (collisionID) references NYCAccidents
);
-- Factors and vehicles involved in an accident.
create table NYCFactors(
collisionID varchar(10) primary key,
factor1 text,
factor2 text,
factor3 text,
factor4 text,
factor5 text,
vehicle1 text,
vehicle2 text,
vehicle3 text,
vehicle4 text,
vehicle5 text,
foreign key (collisionID) references NYCAccidents
);
-- American Holidays throughout the years.
create table USHolidays(
day date not null,
holiday text not null,
primary key (day, holiday)
-- foreign key (day) references NYCDailyWeather(day)
);