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