mirror of
https://github.com/Alvin-Zilverstand/pokedex.git
synced 2026-03-06 13:25:11 +01:00
Add database schema for Pokémon and update get_pokemon.php to include Japanese name
This commit is contained in:
@@ -15,7 +15,7 @@ if ($conn->connect_error) {
|
||||
if (isset($_GET['id'])) {
|
||||
$id = intval($_GET['id']);
|
||||
|
||||
$sql = "SELECT p.id, p.name, p.height, p.weight, p.base_experience, p.image_url, s.genus, s.flavor_text, s.growth_rate, s.base_happiness, s.capture_rate, s.gender_rate, GROUP_CONCAT(DISTINCT t.name) AS types, GROUP_CONCAT(DISTINCT a.name) AS abilities, GROUP_CONCAT(DISTINCT e.name) AS egg_groups, st.hp, st.attack, st.defense, st.sp_attack, st.sp_defense, st.speed
|
||||
$sql = "SELECT p.id, p.name, p.height, p.weight, p.base_experience, p.image_url, s.genus AS japanese_name, s.flavor_text, s.growth_rate, s.base_happiness, s.capture_rate, s.gender_rate, GROUP_CONCAT(DISTINCT t.name) AS types, GROUP_CONCAT(DISTINCT a.name) AS abilities, GROUP_CONCAT(DISTINCT e.name) AS egg_groups, st.hp, st.attack, st.defense, st.sp_attack, st.sp_defense, st.speed
|
||||
FROM pokemon p
|
||||
LEFT JOIN species s ON p.id = s.pokemon_id
|
||||
LEFT JOIN pokemon_types pt ON p.id = pt.pokemon_id
|
||||
|
||||
99
pokedex_database.sql
Normal file
99
pokedex_database.sql
Normal file
@@ -0,0 +1,99 @@
|
||||
CREATE DATABASE IF NOT EXISTS pokedex;
|
||||
USE pokedex;
|
||||
|
||||
-- Table to store Pokémon details
|
||||
CREATE TABLE IF NOT EXISTS pokemon (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
height INT,
|
||||
weight INT,
|
||||
base_experience INT,
|
||||
species_url VARCHAR(255),
|
||||
image_url VARCHAR(255)
|
||||
);
|
||||
|
||||
-- Table to store Pokémon types
|
||||
CREATE TABLE IF NOT EXISTS types (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(50) NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
-- Table to store Pokémon abilities
|
||||
CREATE TABLE IF NOT EXISTS abilities (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(100) NOT NULL
|
||||
);
|
||||
|
||||
-- Table to store Pokémon stats
|
||||
CREATE TABLE IF NOT EXISTS stats (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
pokemon_id INT,
|
||||
hp INT,
|
||||
attack INT,
|
||||
defense INT,
|
||||
sp_attack INT,
|
||||
sp_defense INT,
|
||||
speed INT,
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id)
|
||||
);
|
||||
|
||||
-- Table to store Pokémon type relationships
|
||||
CREATE TABLE IF NOT EXISTS pokemon_types (
|
||||
pokemon_id INT,
|
||||
type_id INT,
|
||||
PRIMARY KEY (pokemon_id, type_id),
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id),
|
||||
FOREIGN KEY (type_id) REFERENCES types(id)
|
||||
);
|
||||
|
||||
-- Table to store Pokémon ability relationships
|
||||
CREATE TABLE IF NOT EXISTS pokemon_abilities (
|
||||
pokemon_id INT,
|
||||
ability_id INT,
|
||||
PRIMARY KEY (pokemon_id, ability_id),
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id),
|
||||
FOREIGN KEY (ability_id) REFERENCES abilities(id)
|
||||
);
|
||||
|
||||
-- Table to store Pokémon evolution chains
|
||||
CREATE TABLE IF NOT EXISTS evolution_chains (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
chain_url VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
-- Table to store Pokémon varieties
|
||||
CREATE TABLE IF NOT EXISTS varieties (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
pokemon_id INT,
|
||||
variety_name VARCHAR(100),
|
||||
image_url VARCHAR(255),
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id)
|
||||
);
|
||||
|
||||
-- Table to store Pokémon species details
|
||||
CREATE TABLE IF NOT EXISTS species (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
pokemon_id INT,
|
||||
genus VARCHAR(100),
|
||||
flavor_text TEXT,
|
||||
growth_rate VARCHAR(100),
|
||||
base_happiness INT,
|
||||
capture_rate INT,
|
||||
gender_rate INT,
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id)
|
||||
);
|
||||
|
||||
-- Table to store Pokémon egg groups
|
||||
CREATE TABLE IF NOT EXISTS egg_groups (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(100) NOT NULL
|
||||
);
|
||||
|
||||
-- Table to store Pokémon egg group relationships
|
||||
CREATE TABLE IF NOT EXISTS pokemon_egg_groups (
|
||||
pokemon_id INT,
|
||||
egg_group_id INT,
|
||||
PRIMARY KEY (pokemon_id, egg_group_id),
|
||||
FOREIGN KEY (pokemon_id) REFERENCES pokemon(id),
|
||||
FOREIGN KEY (egg_group_id) REFERENCES egg_groups(id)
|
||||
);
|
||||
Reference in New Issue
Block a user