Motion database: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
Brian Wilson (talk | contribs)
Line 8: Line 8:
DROP TABLE IF EXISTS vehicle;
DROP TABLE IF EXISTS vehicle;
CREATE TABLE vehicle (
CREATE TABLE vehicle (
   pk CHAR DEFAULT "V",
   tag CHAR NOT NULL DEFAULT "V",
   vehicle_id
   vehicle_id SERIAL NOT NULL,
   name
   name VARCHAR(20),
   description
   description TEXT,
   serial_number
   serial_number VARCHAR(40),
  PRIMARY KEY(tag,vehicle_id)
);
);



Revision as of 06:19, 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 (

 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

);