-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (28 loc) · 1.08 KB
/
Copy pathschema.sql
File metadata and controls
31 lines (28 loc) · 1.08 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
-- Notes:
-- Run this once against your database before running ingest_exoplanets.py
-- psql -U <user> -d exoplanets -f schema.sql
-- export DB_USER=<user> DB_PASSWORD=<password> DB_NAME=exoplanets
-- python ingest_exoplanets.py
CREATE TABLE IF NOT EXISTS exoplanets (
id SERIAL PRIMARY KEY,
pl_name VARCHAR UNIQUE NOT NULL,
hostname VARCHAR,
discovery_year INTEGER,
discovery_method VARCHAR,
orbital_period FLOAT,
planet_radius FLOAT,
planet_mass FLOAT,
distance_ly FLOAT,
star_temp FLOAT,
last_updated TIMESTAMP NOT NULL
);
CREATE TABLE IF NOT EXISTS fetch_log (
id SERIAL PRIMARY KEY,
fetched_at TIMESTAMP NOT NULL,
rows_fetched INTEGER NOT NULL,
status VARCHAR NOT NULL,
error_message VARCHAR
);
CREATE INDEX IF NOT EXISTS idx_exoplanets_radius ON exoplanets (planet_radius);
CREATE INDEX IF NOT EXISTS idx_exoplanets_year ON exoplanets (discovery_year);
CREATE INDEX IF NOT EXISTS idx_exoplanets_method ON exoplanets (discovery_method);