Menu

[r9]: / trunk / bike / sqlall.sql  Maximize  Restore  History

Download this file

32 lines (31 with data), 1.4 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
BEGIN;
CREATE TABLE "bike_ride" (
"id" serial NOT NULL PRIMARY KEY,
"date" date NOT NULL,
"bike_id" integer NOT NULL,
"origin_id" integer NOT NULL,
"destination_id" integer NOT NULL,
"distance" double precision NOT NULL,
"average_speed" double precision NOT NULL,
"fastest_speed" double precision NOT NULL,
"hours" integer NOT NULL,
"minutes" integer NOT NULL,
"seconds" integer NOT NULL
);
CREATE TABLE "bike_bike" (
"id" serial NOT NULL PRIMARY KEY,
"short_name" varchar(100) NOT NULL,
"description" text NOT NULL
);
ALTER TABLE "bike_ride" ADD CONSTRAINT bike_id_refs_id_6cd188d2 FOREIGN KEY ("bike_id") REFERENCES "bike_bike" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE TABLE "bike_location" (
"id" serial NOT NULL PRIMARY KEY,
"short_name" varchar(100) NOT NULL,
"address" text NOT NULL
);
ALTER TABLE "bike_ride" ADD CONSTRAINT origin_id_refs_id_408dbdcc FOREIGN KEY ("origin_id") REFERENCES "bike_location" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "bike_ride" ADD CONSTRAINT destination_id_refs_id_408dbdcc FOREIGN KEY ("destination_id") REFERENCES "bike_location" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "bike_ride_bike_id" ON "bike_ride" ("bike_id");
CREATE INDEX "bike_ride_origin_id" ON "bike_ride" ("origin_id");
CREATE INDEX "bike_ride_destination_id" ON "bike_ride" ("destination_id");
COMMIT;
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.