Game of thrones

 DROP TABLE IF EXISTS king;

DROP TABLE IF EXISTS battle;

CREATE TABLE king (

 k_no INT PRIMARY KEY,

 king VARCHAR(50),

 house VARCHAR(50)

);


-- Create the 'battle' table

CREATE TABLE battle (

 battle_number INT PRIMARY KEY,

 name VARCHAR(100),

 attacker_king INT,

 defender_king INT,

 attacker_outcome INT,

 region VARCHAR(50) 

);

 

INSERT INTO king (k_no, king, house) VALUES

(1, 'Robb Stark', 'House Stark'),

(2, 'Joffrey Baratheon', 'House Lannister'),

(3, 'Stannis Baratheon', 'House Baratheon'),

(4, 'Balon Greyjoy', 'House Greyjoy'),

(5, 'Mace Tyrell', 'House Tyrell'),

(6, 'Doran Martell', 'House Martell');


 

INSERT INTO battle (battle_number, name, attacker_king, defender_king, attacker_outcome, region) VALUES

(1, 'Battle of Oxcross', 1, 2, 1, 'The North'),

(2, 'Battle of Blackwater', 3, 4, 0, 'The North'),

(3, 'Battle of the Fords', 1, 5, 1, 'The Reach'),

(4, 'Battle of the Green Fork', 2, 6, 0, 'The Reach'),

(5, 'Battle of the Ruby Ford', 1, 3, 1, 'The Riverlands'),

(6, 'Battle of the Golden Tooth', 2, 1, 0, 'The North'),

(7, 'Battle of Riverrun', 3, 4, 1, 'The Riverlands'),

(8, 'Battle of Riverrun', 1, 3, 0, 'The Riverlands');


select * from battle;

select * from king;

 

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs