summaryrefslogtreecommitdiffstats
path: root/db_demo/sql/tables/cr_tbl_turn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'db_demo/sql/tables/cr_tbl_turn.sql')
-rw-r--r--db_demo/sql/tables/cr_tbl_turn.sql12
1 files changed, 7 insertions, 5 deletions
diff --git a/db_demo/sql/tables/cr_tbl_turn.sql b/db_demo/sql/tables/cr_tbl_turn.sql
index f0b7cc3..10218e2 100644
--- a/db_demo/sql/tables/cr_tbl_turn.sql
+++ b/db_demo/sql/tables/cr_tbl_turn.sql
@@ -1,9 +1,11 @@
CREATE SEQUENCE seq_turn START 1;
CREATE TABLE tbl_turn (
- key integer PRIMARY KEY, -- primary key
- testid integer NOT NULL REFERENCES tbl_test(key), -- test foreign key
- blockid integer NOT NULL REFERENCES const_block(key), -- block foreign key
- elapsedtime time NOT NULL, -- time in ms.
- holeposition integer NOT NULL -- position of the hole
+ key integer DEFAULT nextval('seq_turn') PRIMARY KEY, -- primary key
+ testid integer NOT NULL REFERENCES tbl_test(key), -- test foreign key
+ blockid integer NOT NULL REFERENCES const_block(key), -- block foreign key
+ elapsedtime time NOT NULL, -- time in ms.
+ holeposition integer NOT NULL, -- position of the hole
+ inserttime timestamp DEFAULT current_timestamp -- time of insertion
+ CONSTRAINT valid_hole CHECK (holeposition >= 0 AND holeposition < 16)
); \ No newline at end of file