diff --git a/legacyworlds-server-data/db-structure/parts/030-data/080-techs.sql b/legacyworlds-server-data/db-structure/parts/030-data/080-techs.sql index c539ac2..a19931a 100644 --- a/legacyworlds-server-data/db-structure/parts/030-data/080-techs.sql +++ b/legacyworlds-server-data/db-structure/parts/030-data/080-techs.sql @@ -3,10 +3,97 @@ -- -- Technology definitions -- --- Copyright(C) 2004-2010, DeepClone Development +-- Copyright(C) 2004-2012, DeepClone Development -- -------------------------------------------------------- +/* + * Technology definitions + * ----------------------- + * + * This table contains all defined technologies. It includes references to + * the various I18N strings used to describe the technology, as well as its + * cost in research points. + * + * FIXME: for now it also includes the monetary cost, but that will go away + * when the full resource system is completed. + */ +CREATE TABLE defs.technologies( + /* Name of the technology (I18N string) */ + technology_name_id INT NOT NULL PRIMARY KEY , + + /* Category of the technology (I18N string) */ + technology_category_id INT NOT NULL , + + /* Text to display when the technology is discovered (I18N string) */ + technology_discovery_id INT NOT NULL , + + /* A more "factual" description of the technology (I18N string) */ + technology_description_id INT NOT NULL , + + /* Monetary price of the technology - FIXME: will be removed later */ + technology_price INT NOT NULL + CHECK( technology_price > 0 ) , + + /* Cost of the technology in terms of research points */ + technology_points INT NOT NULL + CHECK( technology_points > 0 ) +); + +CREATE INDEX idx_techs_category + ON defs.technologies( technology_category_id ); +CREATE UNIQUE INDEX idx_techs_discovery + ON defs.technologies( technology_discovery_id ); +CREATE UNIQUE INDEX idx_techs_description + ON defs.technologies( technology_description_id ); + +ALTER TABLE defs.technologies + ADD CONSTRAINT fk_techs_name + FOREIGN KEY ( technology_name_id ) REFERENCES defs.strings , + ADD CONSTRAINT fk_techs_category + FOREIGN KEY ( technology_category_id ) REFERENCES defs.strings , + ADD CONSTRAINT fk_techs_discovery + FOREIGN KEY ( technology_discovery_id ) REFERENCES defs.strings , + ADD CONSTRAINT fk_techs_description + FOREIGN KEY ( technology_description_id ) REFERENCES defs.strings; + + + +/* + * Technology dependencies + * ------------------------ + * + * This table list dependencies between technologies. It stores pairs of + * dependent / dependency references. + */ +CREATE TABLE defs.technology_dependencies( + /* Identifier of the dependency itself. Makes integrity checks easier */ + techdep_id SERIAL NOT NULL PRIMARY KEY , + + /* Identifier of the dependent technology */ + technology_name_id INT NOT NULL , + + /* Identifier of the technology being depended on */ + technology_name_id_depends INT NOT NULL +); + +CREATE UNIQUE INDEX idx_techdeps_techs + ON defs.technology_dependencies( technology_name_id , technology_name_id_depends ); +CREATE INDEX idx_techdeps_dependency + ON defs.technology_dependencies( technology_name_id_depends ); + +ALTER TABLE defs.technology_dependencies + ADD CONSTRAINT fk_techdeps_dependent + FOREIGN KEY ( technology_name_id ) REFERENCES defs.technologies , + ADD CONSTRAINT fk_techdeps_dependency + FOREIGN KEY ( technology_name_id_depends ) REFERENCES defs.technologies; + + + +/* + * Old B6M1 research system below. + */ + -- -- Technology lines --