Skip to content

Database Schema

Guilherme Pace edited this page Mar 3, 2021 · 14 revisions

Schema for PostgreSQL using SQLAlchemy ORM


Tables

Users

Column Name Data Type Details
id integer not null, primary key
email varchar(255) not null, indexed, unique
first_name varchar(50) not null
last_name varchar(50) not null
country varchar(50) not null
image_url text not null
hashed_password string not null
created_at datetime not null, default = CURRENT_TIMESTAMP
updated_at datetime not null, default = CURRENT_TIMESTAMP

Associations

  • Users have a one to many relationship with Flights
  • Users have a one to many relationship with Comments

Flights

Column Name Data Type Details
id integer not null, primary key
user_id integer foreign key, not null
igc_url text not null
date date not null
duration time not null
distance float not null
location varchar(500) not null
glider_model varchar(50) not null
launch_type varchar(50) not null
notes text
created_at datetime not null, default = CURRENT_TIMESTAMP
updated_at datetime not null, default = CURRENT_TIMESTAMP

Associations

  • Flights have a many to one relationship with Users
  • Flights have a one to many relationship with Comments

Comments

Column Name Data Type Details
id integer not null, primary key
user_id integer foreign key, not null
flight_id integer foreign key, not null
comment text not null
created_at datetime not null, default = CURRENT_TIMESTAMP

Associations

  • Comments have a many to one relationship with Users
  • Comments have a many to one relationship with Flights
Clone this wiki locally