Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions data/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
create database pokedex;

use pokedex;

DROP TABLE IF EXISTS pokemon_type;

DROP TABLE IF EXISTS pokemon;

CREATE TABLE IF NOT EXISTS pokemon (
pokemon_id INT PRIMARY KEY NOT NULL,
name VARCHAR(255) NOT NULL,
color VARCHAR(255),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally dont want to store data related to viewing the data in the database. We should store this on the front end

type VARCHAR(255),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont want to store the types this way. We want to use an many to many relationship

type2 VARCHAR(255),
weakness VARCHAR(255),
pokemon_sprite VARCHAR(555)
);

DROP TABLE IF EXISTS types;

CREATE TABLE IF NOT EXISTS types (
type_id INT PRIMARY KEY NOT NULL auto_increment,
pokemon_type VARCHAR(255) NOT NULL
);

CREATE TABLE IF NOT EXISTS pokemon_type (
pokemon_type_id INT PRIMARY KEY NOT NULL auto_increment,
type_id INT NOT NULL,
pokemon_id INT NOT NULL,
FOREIGN KEY (pokemon_id) REFERENCES pokemon(pokemon_id),
FOREIGN KEY (type_id) REFERENCES types(type_id)
);

INSERT INTO
pokemon (
pokemon_id,
name,
color,
type,
type2,
weakness,
pokemon_sprite
)
VALUES
(
"1",
"bulbasaur",
"green",
"grass",
"poison",
"fire" "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pinterest.com%2Fpin%2F499829258644446405%2F&psig=AOvVaw3uK51ZkPhSismHMgQFUI7l&ust=1614131631809000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCPiUhIbz_u4CFQAAAAAdAAAAABAF"
);

INSERT INTO
types (type_id, pokemon_type)
VALUES
("1", "poison");
24 changes: 21 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ const app = express()
const port = 3000

app.get('/', (req, res) => {
res.send('Hello World!')
res.send('Hello World!')
})

app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
console.log(`Example app listening at http://localhost:${port}`)
})

// app.get('/v3', (req, res) => {

// let sql = new Sql(`mysql://root:${password}@:3306/sample`);

// let Users = sql.define('users', {
// name:
// })

// Users.findAll()
// .then(data => {
// console.log(data);
// return data
// })
// })

let pokemonID = document.getElementById('pokemonId');
let
Loading