generated from admin/template
Обновить works/schema 1.1
This commit is contained in:
+37
-35
@@ -1,9 +1,12 @@
|
||||
CREATE TABLE card_set (
|
||||
set_id text PRIMARY key not null,
|
||||
set_name VARCHAR(255) NOT NULL,
|
||||
set_id VARCHAR(20) PRIMARY key not null,
|
||||
set_code TEXT not null,
|
||||
set_series VARCHAR(20) NOT NULL,
|
||||
set_total_cards INT NOT NULL,
|
||||
set_release_date DATE NOT null
|
||||
set_release_date DATE NOT null,
|
||||
set_logo_url text,
|
||||
set_symbol_url text
|
||||
);
|
||||
|
||||
INSERT INTO card_set (set_name, set_id, set_series, set_total_cards, set_release_date) VALUES
|
||||
@@ -29,18 +32,18 @@ CREATE TABLE card (
|
||||
UNIQUE (card_set_id, card_number)
|
||||
);
|
||||
|
||||
CREATE TABLE card_pokemon (
|
||||
pokemon_card_id INT PRIMARY key references card(card_id),
|
||||
pokemon_pokedex_number INT references pokemon_species(species_pokedex_number) unique,
|
||||
pokemon_pokedex_entry_id INT references pokedex_entry( pokedex_entry_id),
|
||||
CREATE TABLE pokemon_card (
|
||||
pokemon_card_id INT PRIMARY key REFERENCES card(card_id) ON DELETE CASCADE,
|
||||
pokemon_pokedex_number INT REFERENCES pokemon_species(species_pokedex_number) UNIQUE,
|
||||
pokemon_pokedex_entry_id INT REFERENCES pokedex_entry(entry_id),
|
||||
pokemon_hp INT,
|
||||
pokemon_stage TEXT,
|
||||
pokemon_evolves_from TEXT,
|
||||
pokemon_retreat_cost INT check (pokemon_retreat_cost between 0 and 4),
|
||||
pokemon_sub_type_id INT references pokemon_sub_type(sub_type_id),
|
||||
pokemon_retreat_cost INT CHECK (pokemon_retreat_cost BETWEEN 0 AND 4),
|
||||
pokemon_sub_type_id INT REFERENCES pokemon_sub_type(sub_type_id),
|
||||
pokemon_category TEXT,
|
||||
pokemon_printed_height TEXT,
|
||||
pokemon_printed_weight TEXT
|
||||
pokemon_printed_height text,
|
||||
pokemon_printed_weight text
|
||||
);
|
||||
|
||||
CREATE TABLE pokemon_species (
|
||||
@@ -59,27 +62,27 @@ CREATE TABLE pokemon_sub_type (
|
||||
);
|
||||
|
||||
CREATE TABLE pokemon_ability (
|
||||
ability_pokemon_card_id INT PRIMARY KEY,
|
||||
ability_type_id INT NOT null,
|
||||
ability_name VARCHAR(150) NOT NULL,
|
||||
ability_effect_text TEXT NOT NULL,
|
||||
ability_pokemon_card_id INT generated always as identity PRIMARY key REFERENCES pokemon_card(pokemon_card_id) ON DELETE CASCADE,
|
||||
ability_type_id INT REFERENCES ability_type(ability_type_id),
|
||||
ability_name TEXT NOT NULL,
|
||||
ability_effect_text TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE pokemon_attack_link (
|
||||
link_id INT PRIMARY KEY,
|
||||
link_pokemon_card_id INT,
|
||||
link_attack_name_id INT,
|
||||
link_id INT generated always as identity PRIMARY KEY,
|
||||
link_pokemon_card_id INT NOT null REFERENCES pokemon_card(pokemon_card_id) ON DELETE CASCADE,
|
||||
link_attack_name_id INT NOT null REFERENCES attack_name(attack_name_id),
|
||||
link_damage_value TEXT,
|
||||
link_effect_text TEXT,
|
||||
UNIQUE (link_pokemon_card_id, link_attack_name_id)
|
||||
UNIQUE (link_pokemon_card_id, link_attack_name_id
|
||||
);
|
||||
|
||||
CREATE TABLE pokemon_attribute (
|
||||
attribute_id INT PRIMARY KEY,
|
||||
attribute_pokemon_card_id INT NOT null,
|
||||
attribute_energy_type_id INT NOT NULL,
|
||||
attribute_kind TEXT NOT NULL,
|
||||
attribute_modifier_value TEXT NOT NULL,
|
||||
attribute_id INT generated always as identity PRIMARY KEY,
|
||||
attribute_pokemon_card_id INT NOT null REFERENCES pokemon_card(pokemon_card_id) ON DELETE CASCADE,
|
||||
attribute_energy_type_id INT NOT null REFERENCES energy_type(energy_type_id),
|
||||
attribute_kind TEXT NOT null CHECK (attribute_kind IN ('Weakness','Resistance')),
|
||||
attribute_modifier_value TEXT,
|
||||
UNIQUE (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind)
|
||||
);
|
||||
|
||||
@@ -96,8 +99,8 @@ create table trainer_printed_type (
|
||||
);
|
||||
|
||||
CREATE TABLE trainer_mechanic_link (
|
||||
mechanic_link_trainer_card_id INT NOT null REFERENCES trainer_card(trainer_card_id),
|
||||
mechanic_link_mechanic_id INT NOT null REFERENCES game_mechanic(mechanic_id),
|
||||
mechanic_link_trainer_card_id INT NOT null REFERENCES trainer_card(trainer_card_id) on delete cascade,
|
||||
mechanic_link_mechanic_id INT NOT null REFERENCES game_mechanic(mechanic_id) on delete cascade,
|
||||
PRIMARY KEY (mechanic_link_trainer_card_id, mechanic_link_mechanic_id)
|
||||
);
|
||||
|
||||
@@ -123,15 +126,15 @@ CREATE TABLE game_mechanic (
|
||||
);
|
||||
|
||||
CREATE TABLE pokedex_entry (
|
||||
pokedex_entry_id INT PRIMARY KEY,
|
||||
pokedex_entry_pokedex_number INT NOT null references pokemon_species(pokemon_pokedex_number),
|
||||
pokedex_entry_source_game VARCHAR(100) NOT NULL,
|
||||
pokedex_entry_description TEXT NOT NULL
|
||||
entry_id INT PRIMARY KEY,
|
||||
entry_pokedex_number INT NOT null references pokemon_species(pokemon_pokedex_number),
|
||||
entry_source_game VARCHAR(100) NOT NULL,
|
||||
entry_description TEXT NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE attack_energy_cost (
|
||||
cost_id INT generated always as identity PRIMARY KEY,
|
||||
cost_id INT generated always as identity PRIMARY KEY,
|
||||
cost_link_id INT NOT null REFERENCES pokemon_attack_link(link_id) ON DELETE CASCADE,
|
||||
cost_energy_type_id INT NOT null REFERENCES energy_type(energy_type_id),
|
||||
cost_quantity INT NOT null DEFAULT 1 CHECK (cost_quantity > 0)
|
||||
@@ -146,9 +149,8 @@ CREATE TABLE card_attack (
|
||||
);
|
||||
|
||||
CREATE TABLE energy_card (
|
||||
energy_card_id INT PRIMARY KEY,
|
||||
energy_is_special BOOLEAN NOT NULL,
|
||||
energy_main_type_id INT,
|
||||
energy_effect_text TEXT,
|
||||
card_id INT NOT NULL REFERENCES card(card_id)
|
||||
energy_card_id INT PRIMARY key REFERENCES card(card_id) ON DELETE CASCADE,
|
||||
energy_is_special BOOLEAN NOT null default false,
|
||||
energy_main_type_id INT REFERENCES energy_type(energy_type_id),
|
||||
energy_effect_text TEXT
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user