0% found this document useful (0 votes)
21 views2 pages

Games

The document contains SQL code to create multiple database tables - Platform, Games, Country, Developer, GameDeveloper, Genre, and GameGenre. These tables contain fields to store information about video game platforms, individual games, the countries and developers associated with games, and the genres of games. Data is inserted into the tables as examples.

Uploaded by

Sara h
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Games

The document contains SQL code to create multiple database tables - Platform, Games, Country, Developer, GameDeveloper, Genre, and GameGenre. These tables contain fields to store information about video game platforms, individual games, the countries and developers associated with games, and the genres of games. Data is inserted into the tables as examples.

Uploaded by

Sara h
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE TABLE Platform(

platformId int NOT NULL AUTO_INCREMENT,


platformName varchar(50),
PRIMARY KEY (platformId)
);
INSERT INTO Platform(platformName) VALUES ('Xbox'),('PC'),('Playstation'),
('Nintendo'),('Gameboy');

CREATE TABLE Games(


gameName varchar(50),
gameId int NOT NULL AUTO_INCREMENT,
gamePrice double,
gameRank double,
gameBudget int,
platformId int,
PRIMARY KEY (gameId),
FOREIGN KEY (platformId) REFERENCES Platform(platformId)
);
INSERT INTO Games(gameName, gamePrice, gameRank, gameBudget, platformId)
VALUES ('Minecraft',249.99,3.3,10000000,2),
('Call of Duty: Black Ops',199.99,4.5,18000000,1),
('Grand Theft Auto V',179.59,4.6,265000000,3),
('Need For Speed',350.99,3.9,66000000,1),
('The Legend of Zelda: Link''s Awakening',109.99,4.2,4000000,5);

CREATE TABLE Country(


countryId int NOT NULL AUTO_INCREMENT,
countyName varchar(50),
PRIMARY KEY(countryId)
);
INSERT INTO Country (countyName) VALUES ('Sweden'),
('USA'),
('England'),
('Japan');

CREATE TABLE Developer(


developerId int NOT NULL AUTO_INCREMENT,
developerName varchar(50),
countryId int,
FOREIGN KEY (countryId) REFERENCES Country(countryId),
PRIMARY KEY (developerId)
);
INSERT INTO Developer(developerName, countryId) VALUES ('Mojang',1),
('Rockstar games',2),
('Paradox',1),
('Sega',4),
('Nintendo',4),
('Activision Blizzard',2),
('Traveller''s Tales',3),
('Electronic Arts',2),
('Core Design',3),
('Capcom',4);

CREATE TABLE GameDeveloper(


gameDeveloperId INT NOT NULL AUTO_INCREMENT,
gameDeveloperGId INT,
gameDeveloperDId INT,
FOREIGN KEY (gameDeveloperGId) REFERENCES Games(gameId),
FOREIGN KEY (gameDeveloperDId) REFERENCES Developer(developerId),
PRIMARY KEY (gameDeveloperId)

);

INSERT INTO GameDeveloper (gameDeveloperGId, gameDeveloperDId) VALUES


(1,1),(2,6),(3,2);

CREATE TABLE Genre(


genreId int NOT NULL AUTO_INCREMENT,
genreName varchar(50),
PRIMARY KEY(genreId)
);
INSERT INTO Genre(genreName) VALUES ('Horror'),
('Adventure'),
('Simulation'),
('Shooter'),
('Sports');

CREATE TABLE GameGenre(


gameGenre INT NOT NULL AUTO_INCREMENT,
gameGenreGeId INT,
gameGenreGaId INT,
FOREIGN KEY (gameGenreGeId) REFERENCES Genre(genreId),
FOREIGN KEY (gameGenreGaId) REFERENCES Games(gameId),
PRIMARY KEY (gameGenre)
);
INSERT INTO GameGenre(gameGenreGeId, gameGenreGaId) VALUES (1,3),(2,4),
(2,3),(4,3);

You might also like