Files
template/lesson2.sql
T
2026-10-01 07:30:13 +00:00

55 lines
1.4 KiB
SQL

CREATE TABLE card (
card_id int [primary key]
card_name text [not null, unique]
card_hp int [not null]
card_set_id int [not null]
card_illustrator_id int [not null]
);
CREATE TABLE illustrator (
illustrator_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
illustrator_name TEXT NOT NULL
);
CREATE TABLE card_set (
card_set_id int [primary key]
card_set_name text [not null, unique]
card_set_code text [not null, unique]
card_set_release_date date [not null]
);
CREATE TABLE card_attack (
card_attack_id int [primary key]
card_id int [not null]
attack_id int [not null]
);
CREATE TABLE attack (
attack_id int [primary key]
attack_name text [not null]
attack_base_damage int [not null]
);
CREATE TABLE element_type (
element_type_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
element_type_name TEXT NOT NULL UNIQUE
);
CREATE TABLE attack_energy_cost (
attack_energy_cost_id int [primary key]
attack_id int [not null]
element_type_id int [not null]
energy_quantity int [not null]
);
Ref: "card"."card_illustrator_id" > "illustrator"."illustrator_id"
Ref: "card"."card_set_id" ?> "card_set"."card_set_id"
Ref: "card_attack"."card_id" > "card"."card_id"
Ref: "attack"."attack_id" <? "card_attack"."attack_id"
Ref: "attack"."attack_id" <? "attack_energy_cost"."attack_id"
Ref: "attack_energy_cost"."element_type_id" ?> "element_type"."element_id"