Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 4.34 KB | None | 0 0
  1. use [master]
  2.  
  3. IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'BasketballStatistic')
  4.     CREATE DATABASE [BasketballStatistic]
  5. else
  6.     DROP DATABASE [BasketballStatistic]
  7.     CREATE DATABASE [BasketballStatistic]
  8. go
  9. use [BasketballStatistic]
  10.  
  11. CREATE TABLE Team
  12. (
  13. team_id INT IDENTITY(1,1) NOT NULL,
  14.  
  15. team_city VARCHAR(50) NOT NULL,
  16. team_name VARCHAR(50) NOT NULL,
  17. team_fondation_date DateTime Not null,
  18. team_main_stadion int not null,
  19. PRIMARY KEY(team_id)
  20. );
  21.  
  22. CREATE TABLE Team_statistic
  23. (
  24. Team_statistic_id INT IDENTITY(1,1) NOT NULL,
  25. Team_id int not Null,
  26.  
  27. wins int not null,
  28. loses int not null,
  29. loses_on_draw int not null,
  30. wins_on_draw int not null,
  31.  
  32. PRIMARY KEY(Team_statistic_id)
  33. );
  34. /*CREATE TABLE Team_Stadion
  35. (
  36.     Team_Stadion_id INT IDENTITY(1,1) NOT NULL,
  37.     team_id INT not null,
  38.     Stadion_id INT NOT NULL,
  39.     Start_stadion_use DateTime Not null,
  40.     Finish_stadion_use DateTime Not null,
  41.     PRIMARY KEY(Team_Stadion_id)
  42. );*/
  43.  
  44.  
  45. CREATE TABLE Stadion
  46. (
  47. Stadion_id INT IDENTITY(1,1) NOT NULL,
  48.  
  49. Stadion_name VARCHAR(50) NOT NULL,
  50. Stadion_city VARCHAR(50) NOT NULL,
  51. Stadion_fondation_date DateTime Not null,
  52. Stadion_places_count int not null,
  53. Stadion_location_latitude float NOT NULL,
  54. Stadion_location_longitude fload NOT NULL,
  55.  
  56. PRIMARY KEY(Stadion_id)
  57. );
  58.  
  59. CREATE TABLE Players
  60. (
  61. player_id INT IDENTITY(1,1) NOT NULL,
  62. current_team_id int not Null,
  63. player_name VARCHAR(50) NOT NULL,
  64. player_surname VARCHAR(50) NOT NULL,
  65. player_country  VARCHAR(50) NOT NULL,
  66. player_born_date DateTime Not null,
  67. PRIMARY KEY(player_id)
  68. );
  69.  
  70.  
  71. CREATE TABLE Player_Contracts
  72. (
  73. Contract_id INT IDENTITY(1,1) NOT NULL,
  74. team_id int not Null,
  75. player_id int not Null,
  76. player_number int not Null,
  77. contract_start_time DateTime not null,
  78. contract_end_time DateTime not null,
  79. PRIMARY KEY(Contract_id)
  80. );
  81. /**/
  82. CREATE TABLE Player_statistic
  83. (
  84. statistic_id INT IDENTITY(1,1) NOT NULL,
  85. Contract_id int not Null,
  86. one_point int not Null,
  87. two_point int not Null,
  88. three_point int not Null,
  89. fols_commited int not null,
  90. block_shots int not null,
  91. wins int not null,
  92. loses int not null,
  93. loses_on_draw int not null,
  94. wins_on_draw int not null,
  95. contract_end_time DateTime not null,
  96. PRIMARY KEY(statistic_id)
  97. );
  98.  
  99. CREATE TABLE Coach
  100. (
  101. coach_id INT IDENTITY(1,1) NOT NULL,
  102. current_team_id int not Null,
  103. coach_name VARCHAR(50) NOT NULL,
  104. coach_surname VARCHAR(50) NOT NULL,
  105. coach_country  VARCHAR(50) NOT NULL,
  106. coach_born_date DateTime Not null,
  107. PRIMARY KEY(coach_id)
  108. );
  109.  
  110. CREATE TABLE Coach_Contracts
  111. (
  112. Contract_id INT IDENTITY(1,1) NOT NULL,
  113. team_id int not Null,
  114. coach_id int not Null,
  115. contract_start_time DateTime not null,
  116. contract_end_time DateTime not null,
  117. PRIMARY KEY(Contract_id)
  118. );
  119. /**/
  120. CREATE TABLE Coach_statistic
  121. (
  122. statistic_id INT IDENTITY(1,1) NOT NULL,
  123. Contract_id int not Null,
  124.  
  125. wins int not null,
  126. loses int not null,
  127. draws int not null,
  128. loses_on_draw int not null,
  129. wins_on_draw int not null,
  130.  
  131. PRIMARY KEY(statistic_id)
  132. );
  133.  
  134.  
  135. CREATE TABLE referies
  136. (
  137.  referie_id INT IDENTITY(1,1) NOT NULL,
  138.  referie_name VARCHAR(50) NOT NULL,
  139.  referie_surname VARCHAR(50) NOT NULL,
  140.  referie_born_date DateTime Not null,
  141.  referies_status VARCHAR(50) NOT NULL,
  142. PRIMARY KEY(coach_id)
  143.  
  144. PRIMARY KEY(statistic_id)
  145. );
  146.  
  147. /*common table for Tour and team*/
  148.  
  149. CREATE TABLE Tournament
  150. (
  151. Tournament_id INT IDENTITY(1,1) NOT NULL,
  152. Tournament_name VARCHAR(50) NOT NULL,
  153. Tournament_name  VARCHAR(50) NOT NULL,
  154. Tournament_status  VARCHAR(50) NOT NULL,/*international local*/
  155. PRIMARY KEY(Tournament_id)
  156. );
  157.  
  158. CREATE TABLE Game
  159. (
  160. Game_id INT IDENTITY(1,1) NOT NULL,
  161. Tournament_id int NOT NULL,
  162. Stadion_id int not Null,
  163. home_team int not null,
  164. guest_team int not null,
  165. home_team_score int not null,
  166. guest_team_score int not null,
  167. start_time date not null,
  168. PRIMARY KEY(Game_id)
  169. );
  170.  
  171. CREATE TABLE GameApplication
  172. (
  173. GameApplication_id INT IDENTITY(1,1) NOT NULL,
  174. Game_id int NOT NULL,
  175. Player_id int not null,
  176. Team_id int not null,
  177. PRIMARY KEY(GameApplication_id)
  178. );
  179.  
  180.  
  181. CREATE TABLE GameLog
  182. (
  183. GameLog_id INT IDENTITY(1,1) NOT NULL,
  184. Game_id int not null,
  185. /*guest_team int not null,
  186. home_team_score int not null,
  187. guest_team_score int not null,*/
  188. action_time Time not null,
  189. game_period int not null,
  190. player_id int not null,
  191. player_action int not null,/*action of player triger for statistic and score update*/
  192. PRIMARY KEY(GameLog_id)
  193. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement