Salome HOME
Update entities
[modules/gde.git] / projects / GDE_App / src / GDE_DB_Init.sql
1 /* Unique Ids sequence generator */
2
3 drop sequence SEQ_GEN_SEQUENCE;
4 create sequence SEQ_GEN_SEQUENCE INCREMENT BY 50;
5     
6
7 /* METADATA */
8
9 DROP TABLE IF EXISTS attribute_group CASCADE;
10 CREATE TABLE attribute_group (
11     id bigint NOT NULL PRIMARY KEY
12 );
13
14 DROP TABLE IF EXISTS attribute CASCADE;
15 CREATE TABLE attribute (
16     id bigint NOT NULL PRIMARY KEY,
17     name varchar(255),
18     type varchar(255),
19     value varchar(255),
20     attribute_group_id bigint REFERENCES attribute_group (id),
21     mandatory boolean
22 );
23
24
25 /* DATA */
26
27 DROP TABLE IF EXISTS gde_file CASCADE;
28 CREATE TABLE gde_file (
29     id bigint NOT NULL PRIMARY KEY,
30     name varchar(255),
31     length bigint,
32     checksum varchar(255),
33     creation_date timestamp,
34     update_date timestamp,
35     valid boolean,
36     deleted boolean,
37     deletion_date timestamp,
38     attribute_group_id bigint REFERENCES attribute_group (id)
39 );
40
41 DROP TABLE IF EXISTS chunk CASCADE;
42 CREATE TABLE chunk (
43     id bigint NOT NULL PRIMARY KEY,
44     file_id bigint NOT NULL REFERENCES gde_file (id),
45     rank bigint,
46     checksum varchar(255),
47     size bigint,
48     data bytea
49 );
50
51 /* STUDIES */
52
53 DROP TABLE IF EXISTS study CASCADE;
54 CREATE TABLE study (
55     id bigint NOT NULL PRIMARY KEY,
56     name varchar(255),
57     creation_date timestamp,
58     update_date timestamp,
59     valid boolean,
60     deleted boolean,
61     deletion_date timestamp,
62     attribute_group_id bigint REFERENCES attribute_group (id)
63 );
64
65 /* PROFILES */
66
67 DROP TABLE IF EXISTS profile CASCADE;
68 CREATE TABLE profile (
69     id bigint NOT NULL PRIMARY KEY,
70     name varchar(255)
71 );
72
73 DROP TABLE IF EXISTS profile_attribute CASCADE;
74 CREATE TABLE profile_attribute (
75     id bigint NOT NULL PRIMARY KEY,
76     name varchar(255),
77     type varchar(255),
78     mandatory boolean,
79     profile_id bigint REFERENCES profile (id)
80 );