Salome HOME
Fixe entities
[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
24 /* DATA */
25
26 DROP TABLE IF EXISTS gde_file CASCADE;
27 CREATE TABLE gde_file (
28     id bigint NOT NULL PRIMARY KEY,
29     name varchar(255),
30     length bigint,
31     checksum varchar(255),
32     creation_date timestamp,
33     update_date timestamp,
34     valid boolean,
35     deleted boolean,
36     deletion_date timestamp,
37     attribute_group_id bigint REFERENCES attribute_group (id)
38 );
39
40 DROP TABLE IF EXISTS chunk CASCADE;
41 CREATE TABLE chunk (
42     id bigint NOT NULL PRIMARY KEY,
43     file_id bigint NOT NULL REFERENCES gde_file (id),
44     rank bigint,
45     checksum varchar(255),
46     size bigint,
47     data bytea
48 );
49
50 /* STUDIES */
51
52 DROP TABLE IF EXISTS study CASCADE;
53 CREATE TABLE study (
54     id bigint NOT NULL PRIMARY KEY,
55     name varchar(255),
56     creation_date timestamp,
57     update_date timestamp,
58     valid boolean,
59     deleted boolean,
60     deletion_date timestamp,
61     attribute_group_id bigint REFERENCES attribute_group (id)
62 );
63
64 /* PROFILES */
65
66 DROP TABLE IF EXISTS profile CASCADE;
67 CREATE TABLE profile (
68     id bigint NOT NULL PRIMARY KEY,
69     name varchar(255)
70 );
71
72 DROP TABLE IF EXISTS profile_attribute CASCADE;
73 CREATE TABLE profile_attribute (
74     id bigint NOT NULL PRIMARY KEY,
75     name varchar(255),
76     type varchar(255),
77     mandatory boolean,
78     profile_id bigint REFERENCES profile (id)
79 );