-- dataclasses
CREATE TABLE dataclass (dataclass_id INT PRIMARY KEY, dataclass_name TEXT, standard_id INT);
INSERT INTO dataclass (dataclass_id, dataclass_name, dataclass_info) VALUES 
(0, 'no class', 1),
(1, 'class A', 1),
(2, 'class B', 1),
(3, 'class C', 1),
(4, 'class D', 1);
-- valuetypes
CREATE TABLE valuetype (valuetype_id INT PRIMARY KEY, valuetype_name TEXT);
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (1, 'INTEGER');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (2, 'FLOAT');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (3, 'TEXT');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (4, 'PARTIAL DATE');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (6, 'GEOMETRY');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (7, 'POINT');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (8, 'CATEGORICAL');
INSERT INTO valuetype (valuetype_id, valuetype_name) VALUES (9, 'OBJECT');

-- datatypes
CREATE TABLE datatype (
datatype_id SERIAL PRIMARY KEY, 
datatype_name TEXT, 
valuetype_id INT REFERENCES valuetype (valuetype_id) MATCH SIMPLE,
dataclass_id INT REFERENCES dataclass (dataclass_id) MATCH SIMPLE,
standard_id INT REFERENCES standard (standard_id) MATCH SIMPLE,
multilanguage BOOLEAN DEFAULT FALSE,
multivalue BOOLEAN DEFAULT FALSE,
subtypes INT[],

);

COMMENT ON COLUMN datatype.subtypes IS 'list of object subtypes where the datatype is applicable';
COMMENT ON COLUMN datatype.datatype_name IS 'in case of valuetype 8 (categorical) the datatype_name must be the category tablename';

INSERT INTO datatype (datatype_name, valuetype_id, dataclass_id, multilanguage, multivalue)
VALUES
('structure_name', 3, 4, TRUE, FALSE); 
-- datatype
CREATE TABLE datatype (datatype_id SERIAL PRIMARY KEY, datatype_name TEXT, valuetype_id INT, objecttype_id INT, dataclass_id INT, language_dependent INT, multivalue BOOLEAN DEFAULT FALSE, dataformat_id INT, dataimportance_id INT, standard_id INT);

INSERT INTO datatype (datatype_name, valuetype_id, dataclass_id, language_dependent, multivalue)
VALUES
('structure_name', 3, 4, 1, FALSE); 
