-- LegacyWorlds Beta 6 -- PostgreSQL database scripts -- -- System "constants" -- -- Copyright(C) 2004-2010, DeepClone Development -- -------------------------------------------------------- -- -- Constant categories -- CREATE TABLE sys.constant_categories( id SERIAL NOT NULL PRIMARY KEY , name VARCHAR(64) NOT NULL ); CREATE UNIQUE INDEX idx_constantcategories_name ON sys.constant_categories (name); -- -- Constant definitions and values -- CREATE TABLE sys.constant_definitions( name VARCHAR(64) NOT NULL PRIMARY KEY, category_id INT NOT NULL , description TEXT NOT NULL , min_value REAL , max_value REAL , c_value REAL NOT NULL , CHECK( ( min_value IS NULL OR ( min_value IS NOT NULL AND c_value >= min_value ) ) AND ( max_value IS NULL OR ( max_value IS NOT NULL AND max_value >= c_value ) ) ) ); CREATE INDEX idx_constantdefinitions_category ON sys.constant_definitions (category_id); ALTER TABLE sys.constant_definitions ADD CONSTRAINT fk_constraintdefinitions_category FOREIGN KEY (category_id) REFERENCES sys.constant_categories;