generated from admin/template
Обновить shema
This commit is contained in:
@@ -1,74 +1,30 @@
|
|||||||
|
CREATE TABLE card_set (
|
||||||
create table card_set (
|
set_id text PRIMARY key not null,
|
||||||
set_id INT not null generated always as identity primary key,
|
set_name VARCHAR(255) NOT NULL,
|
||||||
set_name VARCHAR(255) not null,
|
set_code TEXT not null,
|
||||||
set_series VARCHAR(20) not null,
|
set_series VARCHAR(20) NOT NULL,
|
||||||
set_total_cards INT 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 (
|
INSERT INTO card_set (set_id, set_name, set_code, set_series, set_total_cards, set_release_date, set_logo_url, set_symbol_url) VALUES
|
||||||
set_name, set_code, set_series,
|
('XY1', 'XY Базовый набор', 'XY1', 'XY', 146, '2014-02-05', NULL, NULL),
|
||||||
set_total_cards, set_release_date,
|
('XY2', 'XY Огненная вспышка', 'XY2', 'XY', 106, '2014-05-07', NULL, NULL),
|
||||||
set_logo_url, set_symbol_url
|
('XY3', 'XY Яростный кулак', 'XY3', 'XY', 111, '2014-08-13', NULL, NULL),
|
||||||
);
|
('XY4', 'XY Призрачные силы', 'XY4', 'XY', 119, '2014-11-05', NULL, NULL),
|
||||||
|
('XY5', 'XY Первобытная дуэль', 'XY5', 'XY', 160, '2015-02-04', NULL, NULL),
|
||||||
|
('XY6', 'XY Грохочущие небеса', 'XY6', 'XY', 108, '2015-05-06', NULL, NULL),
|
||||||
|
('XY7', 'XY Древние истоки', 'XY7', 'XY', 98, '2015-08-12', NULL, NULL),
|
||||||
|
('XY8', 'XY Прорыв', 'XY8', 'XY', 162, '2015-11-04', NULL, NULL),
|
||||||
|
('XY9', 'XY Тайное превосходство', 'XY9', 'XY', 122, '2016-02-03', NULL, NULL),
|
||||||
|
('XY10', 'XY Столкновение судеб', 'XY10', 'XY', 124, '2016-05-02', NULL, NULL);
|
||||||
|
|
||||||
INSERT INTO card_set (set_name, set_id, set_series, set_total_cards, set_release_date) VALUES
|
CREATE TABLE energy_type (
|
||||||
('XY Базовый набор', 'XY1', 'XY', 146, '2014-02-05', NULL, NULL),
|
energy_type_id INT generated always as identity PRIMARY KEY,
|
||||||
('XY Огненная вспышка', 'XY2', 'XY', 106, '2014-05-07', NULL, NULL),
|
energy_type_name TEXT NOT NULL UNIQUE,
|
||||||
('XY Яростный кулак', 'XY3', 'XY', 111, '2014-08-13', NULL, NULL),
|
energy_type_icon_url TEXT
|
||||||
('XY Призрачные силы', 'XY4', 'XY', 119, '2014-11-05', NULL, NULL),
|
|
||||||
('XY Первобытная дуэль', 'XY5', 'XY', 160, '2015-02-04', NULL, NULL),
|
|
||||||
('XY Грохочущие небеса', 'XY6', 'XY', 108, '2015-05-06', NULL, NULL),
|
|
||||||
('XY Древние истоки', 'XY7', 'XY', 98, '2015-08-12', NULL, NULL),
|
|
||||||
('XY Прорыв', 'XY8', 'XY', 162, '2015-11-04', NULL, NULL),
|
|
||||||
('XY Тайное превосходство', 'XY9', 'XY', 122, '2016-02-03', NULL, NULL),
|
|
||||||
('XY Столкновение судеб', 'XY10', 'XY', 124, '2016-05-02', NULL, NULL);
|
|
||||||
|
|
||||||
create table card (
|
|
||||||
card_id INT generated always as identity primary key,
|
|
||||||
card_name TEXT not null,
|
|
||||||
card_number TEXT not null,
|
|
||||||
card_set_id VARCHAR(20) not NULL references card_set(set_id),
|
|
||||||
card_rarity TEXT,
|
|
||||||
card_type TEXT not null check (card_type in ('Pokemon','Trainer','Energy')),
|
|
||||||
card_image_url TEXT,
|
|
||||||
unique (card_set_id, card_number)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table pokemon_card (
|
|
||||||
pokemon_card_id INT generated always as identity primary key references card(card_id) on delete cascade,
|
|
||||||
pokemon_pokedex_number INT references pokemon_species(species_pokedex_number),
|
|
||||||
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_category TEXT,
|
|
||||||
pokemon_printed_height TEXT,
|
|
||||||
pokemon_printed_weight TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO pokemon_card (
|
|
||||||
pokemon_card_id,
|
|
||||||
pokemon_pokedex_number,
|
|
||||||
pokemon_pokedex_entry_id,
|
|
||||||
pokemon_hp,
|
|
||||||
pokemon_stage,
|
|
||||||
pokemon_evolves_from,
|
|
||||||
pokemon_retreat_cost,
|
|
||||||
pokemon_sub_type_id,
|
|
||||||
pokemon_category,
|
|
||||||
pokemon_printed_height,
|
|
||||||
pokemon_printed_weight
|
|
||||||
) VALUES
|
|
||||||
(28, 25, NULL, 60, 'Basic', NULL, 1, 1, 'Мышонок', '0.4 м', '6.0 кг');
|
|
||||||
|
|
||||||
create table energy_type (
|
|
||||||
energy_type_id INT generated always as identity primary key,
|
|
||||||
energy_type_name text unique not null,
|
|
||||||
energy_type_icon_url text
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO energy_type (energy_type_name, energy_type_icon_url) VALUES
|
INSERT INTO energy_type (energy_type_name, energy_type_icon_url) VALUES
|
||||||
@@ -85,25 +41,22 @@ INSERT INTO energy_type (energy_type_name, energy_type_icon_url) VALUES
|
|||||||
('Colorless', NULL);
|
('Colorless', NULL);
|
||||||
|
|
||||||
|
|
||||||
create table pokemon_sub_type (
|
CREATE TABLE pokemon_sub_type (
|
||||||
sub_type_id INT generated always as identity primary key,
|
sub_type_id INT generated always as identity PRIMARY KEY,
|
||||||
sub_type_name TEXT unique not null,
|
sub_type_name TEXT NOT NULL UNIQUE,
|
||||||
sub_type_deafault_prize_count INT not null,
|
sub_type_default_prize_count INT NOT NULL,
|
||||||
sub_type_global_rule_text text
|
sub_type_global_rule_text TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO pokemon_sub_type (
|
INSERT INTO pokemon_sub_type (sub_type_name, sub_type_default_prize_count, sub_type_global_rule_text) VALUES
|
||||||
sub_type_name, sub_type_default_prize_count, sub_type_global_rule_text
|
|
||||||
) VALUES
|
|
||||||
('Normal', 1, NULL),
|
('Normal', 1, NULL),
|
||||||
('EX', 2, 'When a Pokémon-EX is Knocked Out, your opponent takes 2 Prize cards.'),
|
('EX', 2, 'When a Pokémon-EX is Knocked Out, your opponent takes 2 Prize cards.'),
|
||||||
('MEGA', 2, 'When a MEGA Evolution Pokémon is Knocked Out, your opponent takes 2 Prize cards.'),
|
('MEGA', 2, 'When a MEGA Evolution Pokémon is Knocked Out, your opponent takes 2 Prize cards.'),
|
||||||
('BREAK', 1, NULL);
|
('BREAK', 1, NULL);
|
||||||
|
|
||||||
|
CREATE TABLE ability_type (
|
||||||
create table ability_type (
|
ability_type_id INT generated always as identity PRIMARY KEY,
|
||||||
ability_type_id INT generated always as identity primary key,
|
ability_type_name TEXT NOT NULL UNIQUE
|
||||||
ability_type_name TEXT not NULL UNIQUE
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO ability_type (ability_type_name) VALUES
|
INSERT INTO ability_type (ability_type_name) VALUES
|
||||||
@@ -111,9 +64,9 @@ INSERT INTO ability_type (ability_type_name) VALUES
|
|||||||
('Poké-Power'),
|
('Poké-Power'),
|
||||||
('Poké-Body');
|
('Poké-Body');
|
||||||
|
|
||||||
create table attack_name (
|
CREATE TABLE attack_name (
|
||||||
attack_name_id INT generated always as identity primary key,
|
attack_name_id INT generated always as identity PRIMARY KEY,
|
||||||
attack_name_title TEXT not null UNIQUE
|
attack_name_title TEXT NOT NULL UNIQUE
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO attack_name (attack_name_title) VALUES
|
INSERT INTO attack_name (attack_name_title) VALUES
|
||||||
@@ -122,9 +75,9 @@ INSERT INTO attack_name (attack_name_title) VALUES
|
|||||||
('Circle Circuit'),
|
('Circle Circuit'),
|
||||||
('Thunder Shock');
|
('Thunder Shock');
|
||||||
|
|
||||||
create table trainer_printed_type (
|
CREATE TABLE trainer_printed_type (
|
||||||
printed_type_id INT generated always as identity primary key,
|
printed_type_id INT generated always as identity PRIMARY KEY,
|
||||||
printed_type_name text unique not null
|
printed_type_name TEXT NOT NULL UNIQUE
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO trainer_printed_type (printed_type_name) VALUES
|
INSERT INTO trainer_printed_type (printed_type_name) VALUES
|
||||||
@@ -133,37 +86,83 @@ INSERT INTO trainer_printed_type (printed_type_name) VALUES
|
|||||||
('Stadium'),
|
('Stadium'),
|
||||||
('Pokémon Tool');
|
('Pokémon Tool');
|
||||||
|
|
||||||
create table game_mechanic (
|
CREATE TABLE game_mechanic (
|
||||||
mechanic_id INT generated always as identity primary key,
|
mechanic_id INT generated always as identity PRIMARY KEY,
|
||||||
mechanic_name TEXT unique not null
|
mechanic_name TEXT NOT NULL UNIQUE
|
||||||
);
|
);
|
||||||
|
|
||||||
create table pokemon_species (
|
CREATE TABLE pokemon_species (
|
||||||
species_id INT primary key
|
species_id INT PRIMARY KEY,
|
||||||
species_pokedex_number INT unique,
|
species_pokedex_number INT unique,
|
||||||
species_eng_game TEXT not null,
|
species_eng_name TEXT NOT NULL,
|
||||||
species_generation INT,
|
species_generation INT,
|
||||||
species_heigth_m NUMERIC,
|
species_height_m NUMERIC,
|
||||||
species_weigth_m NUMERIC
|
species_weight_kg NUMERIC
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO pokemon_species (pokemon_pokedex_number, species_eng_name, species_generation, species_height_m, species_weight_kg) VALUES
|
INSERT INTO pokemon_species (species_id, species_pokedex_number, species_eng_name, species_generation, species_height_m, species_weight_kg) VALUES
|
||||||
(25, 'Pikachu', 1, 0.4, 6.0),
|
(1, 25, 'Pikachu', 1, 0.4, 6.0),
|
||||||
(26, 'Raichu', 1, 0.8, 30.0),
|
(2, 26, 'Raichu', 1, 0.8, 30.0),
|
||||||
(448, 'Lucario', 4, 1.2, 54.0);
|
(3, 448, 'Lucario', 4, 1.2, 54.0);
|
||||||
|
|
||||||
create table pokedex_entry (
|
|
||||||
entry_id INT primary key,
|
CREATE TABLE pokedex_entry (
|
||||||
entry_pokedex_number INT not null references pokemon_species(species_pokedex_number) on delete cascade,
|
entry_id INT PRIMARY KEY,
|
||||||
|
entry_pokedex_number INT REFERENCES pokemon_species(species_pokedex_number) ON DELETE cascade,
|
||||||
entry_source_game TEXT,
|
entry_source_game TEXT,
|
||||||
entry_description TEXT
|
entry_description TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
create table trainer_card (
|
CREATE TABLE card (
|
||||||
trainer_card_id INT primary key references card(card_id) on delete cascade,
|
card_id INT PRIMARY KEY,
|
||||||
trainer_printed_type_id INT references trainer_printed_type(printed_type_id),
|
card_number TEXT NOT NULL,
|
||||||
|
card_set_id text NOT null REFERENCES card_set(set_id),
|
||||||
|
card_name TEXT NOT NULL,
|
||||||
|
card_rarity TEXT,
|
||||||
|
card_type TEXT NOT null CHECK (card_type IN ('Pokemon','Trainer','Energy')),
|
||||||
|
card_image_url TEXT,
|
||||||
|
UNIQUE (card_set_id, card_number)
|
||||||
|
);
|
||||||
|
|
||||||
|
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_category TEXT,
|
||||||
|
pokemon_printed_height text,
|
||||||
|
pokemon_printed_weight text
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO pokemon_card (
|
||||||
|
pokemon_card_id,
|
||||||
|
pokemon_pokedex_number,
|
||||||
|
pokemon_pokedex_entry_id,
|
||||||
|
pokemon_hp,
|
||||||
|
pokemon_stage,
|
||||||
|
pokemon_evolves_from,
|
||||||
|
pokemon_retreat_cost,
|
||||||
|
pokemon_sub_type_id,
|
||||||
|
pokemon_category,
|
||||||
|
pokemon_printed_height,
|
||||||
|
pokemon_printed_weight
|
||||||
|
) VALUES
|
||||||
|
(28, 25, NULL, 60, 'Basic', NULL, 1, 1, 'Мышонок', '0.4 м', '6.0 кг');
|
||||||
|
-- (28, 28, null, 90, 'Stage 1', null, 1, 1, null, null, null),
|
||||||
|
-- (29, 29, null, 80, 'Basic', null, 2, 1, null, null, null),
|
||||||
|
-- (54, 54, null, 180, 'EX', null, 2, 1, null, null, null),
|
||||||
|
-- (88, 88, null, null, null, null, null, 1, null, null, null),
|
||||||
|
-- (103, 103, null, null, null, null, null, 1, null, null, null);
|
||||||
|
|
||||||
|
CREATE TABLE trainer_card (
|
||||||
|
trainer_card_id INT PRIMARY key REFERENCES card(card_id) ON DELETE CASCADE,
|
||||||
|
trainer_printed_type_id INT REFERENCES trainer_printed_type(printed_type_id),
|
||||||
trainer_effect_text TEXT,
|
trainer_effect_text TEXT,
|
||||||
trainer_is_ace_spec BOOLEAN not null default false
|
trainer_is_ace_spec BOOLEAN NOT null default false
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO trainer_card (
|
INSERT INTO trainer_card (
|
||||||
@@ -172,10 +171,10 @@ INSERT INTO trainer_card (
|
|||||||
) VALUES
|
) VALUES
|
||||||
(88, 2, 'Switch your Active Pokémon with 1 of your Benched Pokémon.', FALSE);
|
(88, 2, 'Switch your Active Pokémon with 1 of your Benched Pokémon.', FALSE);
|
||||||
|
|
||||||
create table energy_card (
|
CREATE TABLE energy_card (
|
||||||
energy_card_id INT primary key references card(card_id) on delete cascade,
|
energy_card_id INT PRIMARY key REFERENCES card(card_id) ON DELETE CASCADE,
|
||||||
energy_is_special BOOLEAN not null default false,
|
energy_is_special BOOLEAN NOT null default false,
|
||||||
energy_main_type_id INT references energy_type(energy_type_id),
|
energy_main_type_id INT REFERENCES energy_type(energy_type_id),
|
||||||
energy_effect_text TEXT
|
energy_effect_text TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -185,68 +184,157 @@ INSERT INTO energy_card (
|
|||||||
) VALUES
|
) VALUES
|
||||||
(103, TRUE, NULL, 'This card provides 1 Fighting energy. When attached, ...');
|
(103, TRUE, NULL, 'This card provides 1 Fighting energy. When attached, ...');
|
||||||
|
|
||||||
create table pokemon_ability (
|
CREATE TABLE pokemon_ability (
|
||||||
ability_pokemon_card_id INT generated always as identity primary key references pokemon_card(pokemon_card_id) on delete cascade,
|
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_type_id INT REFERENCES ability_type(ability_type_id),
|
||||||
ability_name TEXT not null,
|
ability_name TEXT NOT NULL,
|
||||||
ability_effect_text TEXT
|
ability_effect_text TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
create table pokemon_attack_link (
|
CREATE TABLE pokemon_attack_link (
|
||||||
link_id INT generated always as identity primary key,
|
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_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_attack_name_id INT NOT null REFERENCES attack_name(attack_name_id),
|
||||||
link_damage_value TEXT,
|
link_damage_value TEXT,
|
||||||
link_effect_text 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 attack_energy_cost (
|
INSERT INTO pokemon_attack_link (
|
||||||
cost_id INT generated always as identity primary key,
|
link_pokemon_card_id, link_attack_name_id,
|
||||||
cost_link_id INT not null references pokemon_attack_link(link_id) on delete cascade,
|
link_damage_value, link_effect_text
|
||||||
cost_energy_type_id INT references energy_type(energy_type_id),
|
) VALUES
|
||||||
cost_quantity INT not null default 1 check (cost_quantity > 0)
|
(28, 1, '0', 'Your opponent''s Active Pokémon is now Paralyzed.');
|
||||||
|
|
||||||
|
INSERT INTO pokemon_attack_link (
|
||||||
|
link_pokemon_card_id, link_attack_name_id,
|
||||||
|
link_damage_value, link_effect_text
|
||||||
|
) VALUES
|
||||||
|
(28, 2, '20', 'Flip a coin. If heads, this attack does 20 more damage.');
|
||||||
|
|
||||||
|
CREATE TABLE attack_energy_cost (
|
||||||
|
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)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table pokemon_attribute (
|
INSERT INTO attack_energy_cost (cost_link_id, cost_energy_type_id, cost_quantity)
|
||||||
attribute_id INT generated always as identity primary key,
|
VALUES
|
||||||
attribute_pokemon_card_id INT references pokemon_card(pokemon_card_id) on delete cascade,
|
(2, 4, 1), -- Lightning
|
||||||
attribute_energy_type_id INT references energy_type(energy_type_id),
|
(3, 11, 1), -- Colorless
|
||||||
attribute_kind TEXT not null check (attribute_kind in ('Weakness','Resistance')),
|
(1, 4, 1); -- link_id=1, тип Lightning, 1 шт.
|
||||||
|
|
||||||
|
CREATE TABLE pokemon_attribute (
|
||||||
|
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,
|
attribute_modifier_value TEXT,
|
||||||
unique (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind)
|
UNIQUE (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table trainer_mechanic_link (
|
-- Слабость к Fighting
|
||||||
mechanic_link_trainer_card_id INT not null references trainer_card(trainer_card_id) on delete cascade,
|
INSERT INTO pokemon_attribute (
|
||||||
mechanic_link_mechanic_id INT not null references game_mechanic(mechanic_id) on delete cascade,
|
attribute_pokemon_card_id, attribute_energy_type_id,
|
||||||
primary key (mechanic_link_trainer_card_id, mechanic_link_mechanic_id)
|
attribute_kind, attribute_modifier_value
|
||||||
|
) VALUES
|
||||||
|
(28, 6, 'Weakness', 'x2');
|
||||||
|
|
||||||
|
-- Сопротивление Metal
|
||||||
|
INSERT INTO pokemon_attribute (
|
||||||
|
attribute_pokemon_card_id, attribute_energy_type_id,
|
||||||
|
attribute_kind, attribute_modifier_value
|
||||||
|
) VALUES
|
||||||
|
(28, 8, 'Resistance', '-20');
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE trainer_mechanic_link (
|
||||||
|
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)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table staging_furious_fists (
|
SELECT card_id, card_number, card_name FROM card ORDER BY card_id;
|
||||||
card_id INT generated always as identity primary key,
|
SELECT energy_type_id, energy_type_name FROM energy_type;
|
||||||
card_number TEXT,
|
SELECT sub_type_id, sub_type_name FROM pokemon_sub_type;
|
||||||
card_name TEXT,
|
SELECT attack_name_id, attack_name_title FROM attack_name;
|
||||||
card_rarity TEXT,
|
SELECT printed_type_id, printed_type_name FROM trainer_printed_type;
|
||||||
card_type TEXT,
|
|
||||||
card_image_url TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO card (
|
-- 1
|
||||||
card_number, card_set_id, card_name,
|
|
||||||
card_rarity, card_type, card_image_url
|
|
||||||
)
|
|
||||||
SELECT
|
SELECT
|
||||||
s.card_number,
|
c.card_name,
|
||||||
(SELECT set_id FROM card_set WHERE set_code = 'XY3'),
|
pc.pokemon_hp
|
||||||
s.card_name,
|
FROM card c
|
||||||
s.card_rarity,
|
JOIN pokemon_card pc ON pc.pokemon_card_id = c.card_id
|
||||||
s.card_type,
|
WHERE pc.pokemon_hp > 60
|
||||||
s.card_image_url
|
ORDER BY pc.pokemon_hp DESC, c.card_name;
|
||||||
FROM staging_furious_fists s
|
-- 2
|
||||||
WHERE s.card_type IN ('Pokemon', 'Trainer', 'Energy');
|
SELECT
|
||||||
|
an.attack_name_title,
|
||||||
|
pal.link_damage_value
|
||||||
|
FROM pokemon_attack_link pal
|
||||||
|
JOIN attack_name an ON an.attack_name_id = pal.link_attack_name_id
|
||||||
|
ORDER BY pal.link_damage_value DESC NULLS LAST, an.attack_name_title;
|
||||||
|
-- 3
|
||||||
|
SELECT
|
||||||
|
an.attack_name_title,
|
||||||
|
pal.link_damage_value
|
||||||
|
FROM pokemon_attack_link pal
|
||||||
|
JOIN attack_name an ON an.attack_name_id = pal.link_attack_name_id
|
||||||
|
WHERE pal.link_damage_value IS NOT NULL
|
||||||
|
ORDER BY pal.link_damage_value DESC NULLS LAST
|
||||||
|
LIMIT 2;
|
||||||
|
-- 4
|
||||||
|
SELECT
|
||||||
|
c.card_id,
|
||||||
|
c.card_name,
|
||||||
|
c.card_type,
|
||||||
|
c.card_rarity
|
||||||
|
FROM card c
|
||||||
|
WHERE c.card_name ILIKE '%пи%'
|
||||||
|
ORDER BY c.card_name;
|
||||||
|
-- 5
|
||||||
|
SELECT
|
||||||
|
c.card_name,
|
||||||
|
pc.pokemon_stage,
|
||||||
|
pc.pokemon_hp
|
||||||
|
FROM card c
|
||||||
|
JOIN pokemon_card pc ON pc.pokemon_card_id = c.card_id
|
||||||
|
WHERE pc.pokemon_stage = 'Basic'
|
||||||
|
OR pc.pokemon_hp > 100
|
||||||
|
ORDER BY pc.pokemon_hp DESC NULLS LAST, c.card_name;
|
||||||
|
-- 6
|
||||||
|
SELECT
|
||||||
|
et.energy_type_id,
|
||||||
|
et.energy_type_name,
|
||||||
|
et.energy_type_icon_url
|
||||||
|
FROM energy_type et
|
||||||
|
WHERE et.energy_type_name IN ('Fire', 'Water', 'Lightning')
|
||||||
|
ORDER BY et.energy_type_name;
|
||||||
|
|
||||||
|
select
|
||||||
|
c.card_name,
|
||||||
|
pc.pokemon_hp,
|
||||||
|
pc.pokemon_stage
|
||||||
|
from
|
||||||
|
card c
|
||||||
|
inner join
|
||||||
|
pokemon_card pc on c.card_id = pc.pokemon_card_id
|
||||||
|
order by
|
||||||
|
pc.pokemon_hp desc,
|
||||||
|
c.card_name asc;
|
||||||
|
|
||||||
|
select
|
||||||
|
c.card_name,
|
||||||
|
c.card_type,
|
||||||
|
am.attack_name_title,
|
||||||
|
ak.link_damage_value,
|
||||||
|
from
|
||||||
|
card c
|
||||||
|
left join
|
||||||
|
pokemon_card pc
|
||||||
|
|
||||||
DROP TABLE staging_furious_fists;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user