fork download
  1. -- your code goes hereCREATE DATABASE HimalayaDB;
  2. USE HimalayaDB;
  3.  
  4. Create table Mountains(
  5. id int auto_increment primary key,
  6. name varchar(40),
  7. height int,
  8. country varchar(20));
  9.  
  10. create table Mountaineers(
  11. id int auto_increment primary key,
  12. name varchar(40),
  13. nationality varchar(20),
  14. experience int);
  15.  
  16. create table sherpas(
  17. id int auto_increment primary key,
  18. name varchar(40),
  19. nationality varchar(20));
  20.  
  21.  
  22. create table teams(
  23. id int auto_increment primary key,
  24. nationality varchar(20),
  25. country varchar(20));
  26.  
  27. create table expeditions(
  28. id int auto_increment primary key,
  29. mountain_id int,
  30. team_id int,
  31. year int,
  32. foreign key (mountain_id) references mountains(id),
  33. foreign key (team_id) references teams(id));
  34.  
  35. create table exploits(
  36. id int auto_increment primary key,
  37. mountaineer_id int,
  38. expedition_id int,
  39. success boolean,
  40. foreign key (mountaineer_id) references mountaineers(id),
  41. foreign key (expedition_id) references expeditions(id));
  42.  
  43. create table participation(
  44. mountaineer_id int,
  45. expedition_id int,
  46. role varchar(20),
  47. foreign key (mountaineer_id) references mountaineers(id),
  48. foreign key (expedition_id) references expeditions(id));
  49.  
  50.  
  51. INSERT INTO Mountains VALUES
  52. (1,'Everest',8848,'Nepal'),
  53. (2,'K2',8611,'Pakistan'),
  54. (3,'Kangchenjunga',8586,'Nepal/India'),
  55. (4,'Lhotse',8516,'Nepal'),
  56. (5,'Makalu',8485,'Nepal'),
  57. (6,'ChoOyu',8188,'Nepal'),
  58. (7,'Dhaulagiri',8167,'Nepal'),
  59. (8,'Manaslu',8163,'Nepal'),
  60. (9,'NangaParbat',8126,'Pakistan'),
  61. (10,'Annapurna',8091,'Nepal');
  62.  
  63. INSERT INTO Mountaineers VALUES
  64. (1,'Messner'
  65. ,
  66. 'Italy',50),
  67. (2,'Hillary'
  68. ,
  69. 'NZ',30),
  70. (3,'Tenzing'
  71. ,
  72. 'Nepal',25),
  73. (4,'Kukuczka'
  74. ,
  75. 'Poland',40),
  76. (5,'Moro'
  77. ,
  78. 'Italy',20),
  79. (6,'Steck'
  80. ,
  81. 'Swiss',25),
  82. (7,'Purja'
  83. ,
  84. 'Nepal',15),
  85. (8,'Bonington'
  86. ,
  87. 'UK',35),
  88. (9,'Urubko'
  89. ,
  90. 'Kazakh',30),
  91. (10,'Hinkes'
  92. ,
  93. 'UK',28);
  94.  
  95. INSERT INTO Sherpas VALUES
  96. (1,'Kami Rita','Nepal'),
  97. (2,'Apa','Nepal'),
  98. (3,'Phurba','Nepal'),
  99. (4,'Ang Rita','Nepal'),
  100. (5,'Pasang','Nepal'),
  101. (6,'Lakpa','Nepal'),
  102. (7,'Mingma','Nepal'),
  103. (8,'Dawa','Nepal'),
  104. (9,'Pemba','Nepal'),
  105. (10,'Dorje','Nepal');
  106.  
  107.  
  108.  
  109. INSERT INTO Teams VALUES
  110. (1,'Italian Team','Italy'),
  111. (2,'British Team','UK'),
  112. (3,'Nepal Team','Nepal'),
  113. (4,'Polish Team', 'Poland'),
  114. (5,'Swiss Team','Swiss'),
  115. (6,'French Team','France'),
  116. (7,'German Team','Germany'),
  117. (8,'Spanish Team','Spain'),
  118. (9,'US Team','USA'),
  119. (10,'Japan Team','Japan');
  120.  
  121. INSERT INTO Expeditions VALUES
  122. (1,1,3,1953),
  123. (2,2,4,1986),
  124. (3,3,4,1980),
  125. (4,4,1,1970),
  126. (5,5,2,1985),
  127. (6,6,5,2000),
  128. (7,7,6,1990),
  129. (8,8,7,1995),
  130. (9,9,8,2005),
  131. (10,10,9,2010);
  132.  
  133.  
  134. INSERT INTO Exploits VALUES
  135. (1,2,1,TRUE),
  136. (2,3,1,TRUE),
  137. (3,1,2,TRUE),
  138. (4,4,3,TRUE),
  139. (5,5,5, TRUE ), (6,6,6, TRUE ), (7,7,9, TRUE ), (8,8,4, TRUE ), (9,9,2, TRUE ), (10,10,10, TRUE );
  140.  
  141. INSERT INTO Participation VALUES
  142. (1,2,'Leader'),
  143. (2,1,'Leader'),
  144. (3,1,'Guide'),
  145. (4,3,'Leader'),
  146. (5,5,'Climber'),
  147. (6,6,'Climber'),
  148. (7,9,'Leader'),
  149. (8,4,'Climber'),
  150. (9,2,'Climber'),
  151. (10,10,'Leader');
  152.  
  153. alter table mountaineers add age int;
  154.  
  155. alter table teams rename column nationality to climbingTeams;
  156.  
  157. alter table sherpas add experience int;
  158.  
  159.  
Success #stdin #stdout #stderr 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 2: near "USE": syntax error