Motion database

From Wildsong
Jump to navigationJump to search

The Motion Database is used to keep track of my rolling stock including cars and bicycles. It's a demo database for developing concepts in PostgreSQL and Wavemaker.

Table creation SQL

createdb -t template1 motion

DROP TABLE IF EXISTS vehicle; CREATE TABLE vehicle (

 tag CHAR NOT NULL DEFAULT "V",
 vehicle_id SERIAL NOT NULL, 
 name VARCHAR(20),
 description TEXT,
 serial_number VARCHAR(40),
 PRIMARY KEY(tag,vehicle_id)

);

DROP TABLE IF EXISTS photos; CREATE TABLE photos (

 photo_id PRIMARY KEY,
 photo
 description
 location
 fkey

);

DROP TABLE IF EXISTS trips; CREATE TABLE trips (

 pk
 trip_id
 date
 mileage
 vehicle_id
 gpxlog_id
 notes

);

DROP TABLE IF EXISTS maintenance; CREATE TABLE maintenance (

 pk CHAR DEFAULT "M",
 maint_id
 date
 description
 notes
 vehicle_id 

);

DROP TABLE IF EXISTS gpxlog; CREATE TABLE gpxlog (

 gpxlog_id PRIMARY KEY,
 upload_date DATESTAMP,
 log TEXT,
 note TEXT

);