Motion database: Difference between revisions
From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) |
||
Line 6: | Line 6: | ||
createdb -t template1 motion | createdb -t template1 motion | ||
IF EXISTS vehicle | DROP TABLE IF EXISTS vehicle; | ||
CREATE TABLE vehicle ( | CREATE TABLE vehicle ( | ||
pk CHAR DEFAULT "V", | pk CHAR DEFAULT "V", | ||
Line 15: | Line 15: | ||
); | ); | ||
DROP TABLE IF EXISTS photos; | |||
CREATE TABLE photos ( | CREATE TABLE photos ( | ||
photo_id PRIMARY KEY, | photo_id PRIMARY KEY, | ||
Line 23: | Line 24: | ||
); | ); | ||
DROP TABLE IF EXISTS trips; | |||
CREATE TABLE trips ( | CREATE TABLE trips ( | ||
pk | pk | ||
Line 33: | Line 35: | ||
); | ); | ||
DROP TABLE IF EXISTS maintenance; | |||
CREATE TABLE maintenance ( | CREATE TABLE maintenance ( | ||
pk CHAR DEFAULT "M", | pk CHAR DEFAULT "M", | ||
Line 42: | Line 45: | ||
); | ); | ||
DROP TABLE IF EXISTS gpxlog; | |||
CREATE TABLE gpxlog ( | CREATE TABLE gpxlog ( | ||
gpxlog_id PRIMARY KEY, | gpxlog_id PRIMARY KEY, |
Revision as of 06:16, 17 March 2013
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 (
pk CHAR DEFAULT "V", vehicle_id name description serial_number
);
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
);