Technology definition tables
* Added a pair of tables that will contain graph-like technology definitions. The first table describes a technology, while the second table is used to list dependencies between technologies. The new tables contain the basic checks and foreign keys. However, integrity checks on the dependency graph are not implemented. * The following SQL files need to be re-executed: -> 030-data/080-techs.sql
This commit is contained in:
parent
cb65a6e643
commit
b90491ca73
1 changed files with 88 additions and 1 deletions
|
@ -3,10 +3,97 @@
|
||||||
--
|
--
|
||||||
-- Technology definitions
|
-- 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
|
-- Technology lines
|
||||||
--
|
--
|
||||||
|
|
Reference in a new issue