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/080-techs-data.sql

73 lines
1.8 KiB
MySQL
Raw Normal View History

2018-10-23 09:38:02 +02:00
-- LegacyWorlds Beta 6
-- PostgreSQL database scripts
--
-- Technology definitions
--
-- Copyright(C) 2004-2010, DeepClone Development
-- --------------------------------------------------------
--
2018-10-23 09:43:42 +02:00
-- Categories
2018-10-23 09:38:02 +02:00
--
2018-10-23 09:43:42 +02:00
CREATE TABLE tech.categories(
2018-10-23 09:38:02 +02:00
name_id INT NOT NULL PRIMARY KEY ,
description_id INT NOT NULL
);
2018-10-23 09:43:42 +02:00
CREATE INDEX idx_categories_description
ON tech.categories (description_id);
2018-10-23 09:38:02 +02:00
2018-10-23 09:43:42 +02:00
ALTER TABLE tech.categories
ADD CONSTRAINT fk_categories_name
2018-10-23 09:38:02 +02:00
FOREIGN KEY (name_id) REFERENCES defs.strings ,
2018-10-23 09:43:42 +02:00
ADD CONSTRAINT fk_categories_description
2018-10-23 09:38:02 +02:00
FOREIGN KEY (description_id) REFERENCES defs.strings;
2018-10-23 09:43:42 +02:00
2018-10-23 09:38:02 +02:00
--
2018-10-23 09:43:42 +02:00
-- Technologies
2018-10-23 09:38:02 +02:00
--
2018-10-23 09:43:42 +02:00
CREATE TABLE tech.technologies(
name_id INT NOT NULL PRIMARY KEY ,
2018-10-23 09:38:02 +02:00
description_id INT NOT NULL ,
2018-10-23 09:43:42 +02:00
category_id INT NOT NULL ,
2018-10-23 09:38:02 +02:00
points INT NOT NULL CHECK( points > 0 ) ,
cost INT NOT NULL CHECK( cost > 0 )
);
2018-10-23 09:43:42 +02:00
CREATE INDEX idx_technologies_description
ON tech.technologies (description_id);
CREATE INDEX idx_technologies_category
ON tech.technologies (category_id);
ALTER TABLE tech.technologies
ADD CONSTRAINT fk_technologies_category
FOREIGN KEY (category_id) REFERENCES tech.categories ,
ADD CONSTRAINT fk_technologies_name
2018-10-23 09:38:02 +02:00
FOREIGN KEY (name_id) REFERENCES defs.strings ,
2018-10-23 09:43:42 +02:00
ADD CONSTRAINT fk_technologies_description
2018-10-23 09:38:02 +02:00
FOREIGN KEY (description_id) REFERENCES defs.strings;
2018-10-23 09:43:42 +02:00
--
-- Dependencies
--
CREATE TABLE tech.dependencies(
technology_id INT NOT NULL ,
depends_on INT NOT NULL ,
PRIMARY KEY( technology_id , depends_on )
);
CREATE INDEX idx_dependencies_dependson
ON tech.dependencies (depends_on);
ALTER TABLE tech.dependencies
ADD CONSTRAINT fk_dependencies_technology
FOREIGN KEY (technology_id) REFERENCES tech.technologies ,
ADD CONSTRAINT fk_dependencies_dependson
FOREIGN KEY (depends_on) REFERENCES tech.technologies;