Advertisement
GLASHATAY_007

create db

Apr 20th, 2023 (edited)
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 8.08 KB | None | 0 0
  1. CREATE TABLE faculty_name (
  2.   id   SERIAL PRIMARY KEY,
  3.   name VARCHAR(40)
  4. );
  5.  
  6. CREATE TABLE subject_type (
  7.   id   SERIAL PRIMARY KEY,
  8.   name VARCHAR(40)
  9. );
  10.  
  11. CREATE TABLE students (
  12.   id         SERIAL PRIMARY KEY,
  13.   name       VARCHAR(40) ,
  14.   faculty_id   INT     NULL REFERENCES faculty_name (id)
  15. );
  16.  
  17.  
  18. CREATE TABLE mark (
  19.   id   SERIAL PRIMARY KEY,
  20.   student_id   INT     NULL REFERENCES students (id),
  21.   subject_id   INT    NULL REFERENCES subject_type (id),
  22.   mark INT
  23. );
  24.  
  25. INSERT INTO faculty_name (name)
  26. VALUES ('Gryffindor'), ('Hufflepuff'),('Ravenclaw'), ('Slytherin');
  27.  
  28. INSERT INTO students (name,faculty_id)
  29. VALUES ('Marietta Edgecombe',1),
  30. ('Mandy Brocklehurst',2),
  31. ('Michael Corner',2),
  32. ('Stephen Cornfoot',1),
  33. ('Kevin Entwhistle',2),
  34. ('Anthony Goldstein',3),
  35. ('Alena Irkhina',2),
  36. ('Morag McDougal',1),
  37. ('Padma Patil',2),
  38. ('Lisa Turpin',3),
  39. ('Luna Lovegood',3),
  40. ('Orla Quirke',1),
  41. ('Stewart Ackerley',4),
  42. ('Susan Bones',4),
  43. ('Eleanor Branstone',4),
  44. ('Owen Cauldwell',2),
  45. ('Justin Finch-Fletchley',4),
  46. ('Wayne Hopkins',4),
  47. ('Megan Jones',3),
  48. ('Laura Madley',1),
  49. ('Kevin Whitby',3),
  50. ('Rose Zeller',3),
  51. ('Terence Higgs',4),
  52. ('Adrian Pucey',4),
  53. ('Tracey Davis',1),
  54. ('Lilian Moon',2),
  55. ('Daphne Greengrass',1),
  56. ('Andrei Osadchii',3),
  57. ('Astoria Greengrass',2),
  58. ('Malcolm Baddock',3),
  59. ('Graham Pritchard',4),
  60. ('Roger Davies',1);
  61.  
  62. INSERT INTO subject_type (name)
  63. VALUES ('Defense Against the Dark Arts'), ('Charms'),('Transfiguration'), ('Potions'), ('Herbology'), ('History of Magic'), ('Astronomy'), ('Flying'), ('Muggle Art');
  64.  
  65. INSERT INTO mark (student_id,subject_id,mark)
  66. (SELECT * FROM
  67. (SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  68. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  69. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  70. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  71. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  72. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  73. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  74. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  75. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  76. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  77. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  78. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  79. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  80. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  81. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  82. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  83. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  84. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  85. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  86. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  87. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  88. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  89. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  90. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  91. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  92. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  93. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  94. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  95. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  96. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  97. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  98. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  99. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  100. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  101. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  102. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  103. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  104. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  105. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  106. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  107. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  108. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  109. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  110. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  111. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  112. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  113. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  114. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  115. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  116. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  117. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  118. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  119. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  120. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  121. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  122. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  123. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  124. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  125. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  126. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  127. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  128. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  129. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  130. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  131. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  132. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  133. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  134. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  135. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  136. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  137. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  138. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  139. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  140. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  141. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  142. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  143. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  144. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  145. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  146. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  147. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  148. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  149. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  150. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  151. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  152. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  153. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  154. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  155. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  156. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  157. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  158. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  159. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  160. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  161. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  162. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  163. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  164. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  165. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  166. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  167. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  168. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  169. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  170. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5) UNION
  171. SELECT CEIL(RAND()*32), CEIL(RAND()*9)  ,CEIL(RAND()*5))s)
  172. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement