Обновить works/schema 1.1

This commit is contained in:
Fan
2026-09-30 10:07:52 +00:00
parent 4c2497c7a3
commit 99536ec112
+29 -34
View File
@@ -21,34 +21,34 @@ INSERT INTO card_set (set_name, set_id, set_series, set_total_cards, set_release
CREATE TABLE card (
card_id INT PRIMARY KEY,
card_number TEXT NOT NULL,
card_set_id VARCHAR(20) NOT null,
card_set_id VARCHAR(20) NOT null references card_set(set_id),
card_name TEXT NOT NULL,
card_rarity TEXT,
card_type TEXT NOT null,
card_type TEXT NOT null check (card_type in ('Pokemon', 'Trainer', 'Energy')),
card_image_url TEXT,
UNIQUE (card_set_id, card_number)
);
CREATE TABLE card_pokemon (
pokemon_card_id INT PRIMARY key,
pokemon_pokedex_number INT,
pokemon_pokedex_entry_id INT,
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),
pokemon_hp INT,
pokemon_stage TEXT,
pokemon_evolves_from TEXT,
pokemon_retreat_cost INT,
pokemon_sub_type_id INT,
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
);
CREATE TABLE pokemon_species (
pokemon_species_pokedex_number INT PRIMARY KEY,
pokemon_species_end_name VARCHAR(150) NOT NULL,
pokemon_species_generation INT NOT NULL,
pokemon_species_height_m FLOAT NOT NULL,
pokemon_species_weight_kg FLOAT NOT NULL
species_pokedex_number INT PRIMARY KEY,
species_end_name VARCHAR(150) NOT NULL,
species_generation INT NOT NULL,
species_height_m FLOAT NOT NULL,
species_weight_kg FLOAT NOT NULL
);
CREATE TABLE pokemon_sub_type (
@@ -83,36 +83,30 @@ CREATE TABLE pokemon_attribute (
UNIQUE (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind)
);
CREATE TABLE coach_card (
couch_card_id INT PRIMARY key,
couch_printed_type_id INT,
couch_effect_text TEXT,
couch_is_ace_spec BOOLEAN NOT null default false
CREATE TABLE triner_card (
coach_card_id INT PRIMARY key references card(card_id),
coach_printed_type_id INT references trainer_printed_type(printed_type_id),
coach_effect_text TEXT,
coach_is_ace_spec BOOLEAN NOT null default false
);
create table trainer_printed_type (
printed_type_id INT generated always as identity PRIMARY key,
printed_type_name TEXT NOT NULL UNIQUE
);
CREATE TABLE trainer_mechanic_link (
mechanic_link_trainer_card_id INT NOT null,
mechanic_link_mechanic_id INT NOT null,
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),
PRIMARY KEY (mechanic_link_trainer_card_id, mechanic_link_mechanic_id)
);
create table couch_printed_type (
couch_type_id INT PRIMARY KEY,
couch_type_name TEXT NOT NULL UNIQUE
);
CREATE TABLE energy_type (
energy_type_id INT primary key,
energy_type_name TEXT NOT NULL UNIQUE,
energy_type_icon_url TEXT
);
CREATE TABLE illustrator (
illustrator_id INT PRIMARY KEY,
illustrator_name VARCHAR(150) NOT NULL UNIQUE,
illustrator_nationality VARCHAR(100)
);
CREATE TABLE ability_type (
ability_type_id INT PRIMARY KEY,
ability_type_name TEXT NOT NULL
@@ -130,16 +124,17 @@ CREATE TABLE game_mechanic (
CREATE TABLE pokedex_entry (
pokedex_entry_id INT PRIMARY KEY,
pokedex_entry_pokedex_number INT NOT NULL,
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
);
CREATE TABLE attack_energy_cost (
attack_energy_cost_id INT PRIMARY KEY,
attack_id INT NOT NULL REFERENCES attack(attack_id),
element_type_id INT NOT NULL REFERENCES energy_type(element_type_id)
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)
);