Advertisement
Guest User

Untitled

a guest
Feb 15th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. CREATE table Player (
  2. USERNAME INT PRIMARY KEY,
  3. name VARCHAR (30),
  4. email VARCHAR (100),
  5. address VARCHAR (100),
  6. balance INT
  7.  
  8. ) ENGINE = INNODB;
  9.  
  10. CREATE table PowerUp (
  11. ID VARCHAR(5) PRIMARY KEY,
  12. PowerUpName VARCHAR (30),
  13. cost INT
  14. ) ENGINE = INNODB;
  15.  
  16. CREATE table Games (
  17. PlayerUserName INT PRIMARY KEY,
  18. WordStew BOOLEAN,
  19. SweetieSqueeze BOOLEAN,
  20. CharacterHunt BOOLEAN,
  21. FOREIGN KEY (PlayerUserName) REFERENCES Player(USERNAME)
  22. ) ENGINE = INNODB;
  23.  
  24. CREATE table GamePowerUp (
  25. PlayerUserName INT,
  26. PowerUpID VARCHAR(5),
  27. counter INT,
  28. FOREIGN KEY (PlayerUserName) REFERENCES Player(USERNAME),
  29. FOREIGN KEY (PowerUpID) REFERENCES PowerUp(ID)
  30. ) ENGINE = INNODB;
  31.  
  32. CREATE table DailyBonus (
  33. PlayerUserName INT,
  34. PlaysWordStew BOOLEAN,
  35. PlaysSweetieSqueeze BOOLEAN,
  36. PlaysCharacterHunt BOOLEAN,
  37. PowerUp VARCHAR(5),
  38. CheckLogin BOOLEAN,
  39. FOREIGN KEY (PowerUp) REFERENCES GamePowerUp(PowerUpID),
  40. FOREIGN KEY (PlayerUserName) REFERENCES Player(USERNAME)
  41. ) ENGINE = INNODB;
  42.  
  43. INSERT INTO Player VALUES (1, "Euan", "euan@example.com", "12 cresent avenue", 0);
  44. INSERT INTO Player VALUES (2, "Lewis", "lewis@example.com", "15 mars road", 5);
  45. INSERT INTO Player VALUES (3, "Kamil", "kamil@example.com", "36 dodger street", 3);
  46. INSERT INTO Player VALUES (4, "Josie", "josie@example.com", "78 smith street", 1);
  47. INSERT INTO Player VALUES (5, "Mark", "mark@example.com", "9 thompson street", 0);
  48.  
  49. INSERT INTO PowerUp VALUES ("ss1", "Clear row", 2);
  50. INSERT INTO PowerUp VALUES ("ss2", "Clear column", 2);
  51. INSERT INTO PowerUp VALUES ("ss3", "Clear colour", 4);
  52. INSERT INTO PowerUp VALUES ("ws1", "Give clue", 2);
  53. INSERT INTO PowerUp VALUES ("ws2", "Give word", 5);
  54. INSERT INTO PowerUp VALUES ("ch1", "Extra turn",4);
  55. INSERT INTO PowerUp VALUES ("ch2", "Give character",2);
  56.  
  57. INSERT INTO Games VALUES (1, true, false,true);
  58. INSERT INTO Games VALUES (2, true, false,false);
  59. INSERT INTO Games VALUES (3, false, true,false);
  60. INSERT INTO Games VALUES (4, true, false,true);
  61. INSERT INTO Games VALUES (5, true, true,false);
  62.  
  63. INSERT INTO GamePowerUp VALUES(1, "ss1" ,1);
  64. INSERT INTO GamePowerUp VALUES(1, "ws1" ,1);
  65. INSERT INTO GamePowerUp VALUES(1, "ch1",0);
  66. INSERT INTO GamePowerUp VALUES(2, "ss1" ,1);
  67. INSERT INTO GamePowerUp VALUES(2, "ws1" ,1);
  68. INSERT INTO GamePowerUp VALUES(3, "ss3" ,0);
  69. INSERT INTO GamePowerUp VALUES(4, "ws1" ,0);
  70. INSERT INTO GamePowerUp VALUES(4, "ch2" ,1);
  71. INSERT INTO GamePowerUp VALUES(5, "ws2", 0);
  72.  
  73.  
  74. INSERT INTO DailyBonus VALUES(1, false, true,false, "ss1",true);
  75. INSERT INTO DailyBonus VALUES(1, true, false,false, "ws1",true);
  76. INSERT INTO DailyBonus VALUES(1, false,false,true,"ch1",false);
  77. INSERT INTO DailyBonus VALUES(2, false, false,false, "ss3",false);
  78. INSERT INTO DailyBonus VALUES(3, true, false,false, "ws2",true);
  79. INSERT INTO DailyBonus VALUES(3, false, true, false,"ss3",false);
  80. INSERT INTO DailyBonus VALUES(4, true, false,false,"ws1",true);
  81. INSERT INTO DailyBonus VALUES(4, false, false,true, "ch2",false);
  82. INSERT INTO DailyBonus VALUES(5, true, false,false,"ws1",false);
  83.  
  84. UPDATE Player SET email = "LewisWilson@gmail.com" WHERE name = "Lewis";
  85. ALTER TABLE Player DROP COLUMN Address;
  86.  
  87.  
  88.  
  89.  
  90. //COMMANDS
  91.  
  92. SELECT PlayerUserName FROM Games WHERE SweetieSqueeze = true;
  93.  
  94. SELECT counter AS "2B. Number of give clue’ power-ups Lewis has got" FROM GamePowerUp WHERE PowerUpID = "ws1" AND PlayerUserName = 2;
  95.  
  96.  
  97. SELECT COUNT(counter) AS "2C. The total number of ‘clear row’ power-ups all users have got" FROM GamePowerUp WHERE PowerUpID = "ss1";
  98.  
  99.  
  100. SELECT email AS "2D. The email address of Euan." FROM Player WHERE name = "Euan";
  101.  
  102.  
  103. SELECT COUNT(SweetieSqueeze AND WordStew) AS "2E. The number of users who are signed up to both games." FROM Games WHERE SweetieSqueeze = true AND WordStew = true;
  104.  
  105. SELECT name, balance FROM Player WHERE name = "Kamil";
  106. SELECT * FROM Player WHERE balance > 0;
  107.  
  108. SELECT * FROM DailyBonus WHERE CheckLogin = true;
  109.  
  110. SELECT email AS "3a. Showing updated email" FROM Player WHERE name = "Lewis";
  111.  
  112. SELECT * FROM Games;
  113. SELECT * FROM PowerUp;
  114.  
  115. SELECT * FROM Player;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement