create table card_set (
card_id int generated always as identity primary key,
set_name text not null,
set_code text not null,
set_series text not null,
set_total_cards int not null,
set_realese_date date not null,
set_logo_url text  null,
set_symbol_url text  null
);

INSERT INTO card_set (
    set_name, set_code, set_series,
    set_total_cards, set_realese_date,
    set_logo_url, set_symbol_url
)
VALUES
    ('XY Базовый набор', 'XY1', 'XY', 146, '2014-02-05', NULL, NULL),
    ('XY Огненная вспышка', 'XY2', 'XY', 106, '2014-05-07', NULL, NULL),
    ('XY Яростный кулак', 'XY3', 'XY', 111, '2014-08-13', NULL, NULL),
    ('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 energy_type(
energy_type_id int  generated always as identity primary key,
energy_type_name text  null,
energy_type_icon_url text  null
);

INSERT into energy_type (
energy_type_name,energy_type_icon_url
) VALUES
    ('Grass',     NULL),
    ('Fire',      NULL),
    ('Water',     NULL),
    ('Lightning', NULL),
    ('Psychic',   NULL),
    ('Fighting',  NULL),
    ('Darkness',  NULL),
    ('Metal',     NULL),
    ('Fairy',     NULL),
    ('Dragon',    NULL),
    ('Colorless', NULL);

create table pokemon_sub_type(
sub_type_id int generated always as identity primary key,
sub_type_name text  null,
sub_type_default_prize_count int  null,
sub_type_global_rule_text text null
);
INSERT INTO pokemon_sub_type (
    sub_type_name, sub_type_default_prize_count, sub_type_global_rule_text
) VALUES
    ('Normal', 1, NULL),
    ('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.'),
    ('BREAK',  1, NULL);


create table ability_type (
ability_type_id int  generated always as identity primary key,
ability_type_name text not null
);
INSERT INTO ability_type (ability_type_name) VALUES
    ('Ability'),
    ('Poké-Power'),
    ('Poké-Body');

create table attack_name (
attack_name_id int  generated always as identity primary key,
attack_name_tittle text not null
);
INSERT INTO attack_name (attack_name_tittle) VALUES
    ('Nuzzle'),
    ('Quick Attack'),
    ('Circle Circuit'),
    ('Thunder Shock');

create table trainer_printed_type (
printed_type_id int generated always as identity primary key,
printed_type_name text not null
);
INSERT INTO trainer_printed_type (printed_type_name) VALUES
    ('Item'),
    ('Supporter'),
    ('Stadium'),
    ('Pokémon Tool');
create table game_mechanic(
mechanic_id int generated always as identity primary key,
mechanic_name text not null
);

create table pokemon_species (
spesies_pokedex_number int primary key,
spesies_eng_name text  unique not null,
spesies_generation int not null,
spesies_weight_kg numeric not null,
spesies_height_m numeric not null
);
INSERT INTO pokemon_species (
    spesies_pokedex_number, spesies_eng_name,
    spesies_generation, spesies_height_m, spesies_weight_kg
) VALUES
    (25,  'Pikachu',  1, 0.4, 6.0),
    (26,  'Raichu',   1, 0.8, 30.0),
    (448, 'Lucario',  4, 1.2, 54.0);
create table pokedex_entry (
entry_id int generated always as identity primary key,
entry_pokedex_number int references pokemon_species(spesies_pokedex_number),
entry_sourse_game text not null,
entry_discription text not null
);

create table card (
card_id int references card_set(card_id)
card_number int not null,
card_name text not null,
card_rarity text not null,
card_type text not null,
card_imagine_url text not null
);

create table pokemon_card (
	pokemon_card_id INT [primary key, auto_increment]
 	pokemon_card_name TEXT UNIQUE NOT null,
 	pokemon_stage TEXT NOT null,
 	pokemon_hp INT or NUMERIC NOT NULL check,
 	pokemon_pokedex_number INT UNIQUE NOT null,
 	pokemon_category TEXT NOT null,
 	pokemon_height numeric NOT null,
 	pokemon_weight numeric NOT null,
	pokemon_retreat_cost INT or numeric,
	pokemon_release_date DATE NOT NULL
)

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 кг');

