This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb6/legacyworlds-server/legacyworlds-server-data/db-structure/parts/data/070-constants-data.sql

44 lines
1.1 KiB
MySQL
Raw Normal View History

2018-10-23 09:38:02 +02:00
-- 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;