CREATE SEQUENCE id_user_seq CREATE SEQUENCE id_type_seq CREATE SEQUENC

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
CREATE SEQUENCE id_user_seq;
CREATE SEQUENCE id_type_seq;
CREATE SEQUENCE id_day_seq;
CREATE SEQUENCE id_people_seq;
CREATE TABLE users
(
ulogin character(200) NOT NULL,
upassword character(200) NOT NULL,
uid integer NOT NULL DEFAULT nextval('id_user_seq'::regclass),
CONSTRAINT uid PRIMARY KEY (uid)
);
CREATE TABLE types
(
caption character(200) NOT NULL,
description character(200) NOT NULL,
tid integer NOT NULL DEFAULT nextval('id_type_seq'::regclass),
CONSTRAINT tid PRIMARY KEY (tid)
);
CREATE TABLE people
(
name character(200) NOT NULL,
description character(200) NOT NULL,
email character(200),
cell character(200),
pid integer NOT NULL DEFAULT nextval('id_people_seq'::regclass),
CONSTRAINT pid PRIMARY KEY (pid)
);
CREATE TABLE days
(
description character(200) NOT NULL,
ddate timestamp without time zone NOT NULL,
did integer NOT NULL DEFAULT nextval('id_day_seq'::regclass),
pid integer NOT NULL,
tid integer NOT NULL,
CONSTRAINT did PRIMARY KEY (did),
CONSTRAINT pid FOREIGN KEY (pid)
REFERENCES people (pid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT tid FOREIGN KEY (tid)
REFERENCES types (tid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)