fork download
  1. =============================================University Db==============================================
  2. -- task 1: (create nam)
  3. CREATE TABLE students(
  4. stuID INT PRIMARY KEY,
  5. nam VARCHAR(50),
  6. dept VARCHAR(50)
  7. );
  8.  
  9. -- task 2: (insert info)
  10. INSERT INTO students (stuID, nam, dept) VALUES
  11. (1, 'rahim', 'cse'),
  12. (2, 'tanjin', 'bba'),
  13. (3, 'karim', 'eee'),
  14. (4, 'tajrin', 'cse'),
  15. (5, 'jerin', 'cse');
  16.  
  17. -- task 3: (fragmantation student 1)
  18. CREATE TABLE student1 AS
  19. SELECT *
  20. FROM students
  21. WHERE dept = 'cse'
  22.  
  23. -- task 4: (fragmantation student 2)
  24. CREATE TABLE student2 AS
  25. SELECT *
  26. FROM students
  27. WHERE dept != 'cse'
  28.  
  29. -- task 5 set primary key in student 1 table
  30. ALTER TABLE student1
  31. ADD PRIMARY KEY(stuID)
  32.  
  33. -- task 6 set primary key in student 2 table
  34. ALTER TABLE student2
  35. ADD PRIMARY KEY(stuID)
  36.  
  37. -- task 7 union student 1 & student 2 table
  38. CREATE TABLE studentUnio AS
  39. SELECT * FROM student1
  40. UNION
  41. SELECT * FROM student2
  42. =====================================================================================================
  43.  
  44. =========================================== vertical fragmantation =======================================
  45. -- vertical table (student vf1)
  46. CREATE TABLE studentVF1 AS
  47. SELECT stuID, nam
  48. FROM students;
  49.  
  50. ALTER TABLE studentVF1
  51. ADD PRIMARY KEY (stuID);
  52.  
  53. -- vertical table (student vf2)
  54. CREATE TABLE studentVF2 AS
  55. SELECT stuID, dept
  56. FROM students;
  57.  
  58. ALTER TABLE studentVF2
  59. ADD PRIMARY KEY (stuID);
  60.  
  61. -- join table
  62. CREATE TABLE studentJoin AS
  63. SELECT studentVF1.stuID, nam, dept
  64. FROM studentVF1
  65. INNER JOIN studentVF2 ON studentVF1.stuID = studentVF2.stuID
  66. =====================================================================================================
Success #stdin #stdout #stderr 0.01s 5260KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 1: near "==": syntax error
Error: near line 10: no such table: students
Error: near line 18: near "CREATE": syntax error
Error: near line 50: no such table: studentVF1
Error: near line 54: no such table: students
Error: near line 58: no such table: studentVF2
Error: near line 62: near "==": syntax error