mikeyworx

MIDTERM EXAMINATION

May 30th, 2023
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.65 KB | Source Code | 0 0
  1. -- JOHN MICHAEL GONZALES
  2. -- BSIT          CUBAO2
  3. -- MIDTERM EXAMINATION
  4.  
  5.  
  6. -- Create the infoman database
  7. CREATE DATABASE ONEPIECE;
  8. USE ONEPIECE;
  9.  
  10. -- Create the Characters table
  11. CREATE TABLE Characters (
  12.   character_id INT PRIMARY KEY,
  13.   name VARCHAR(255),
  14.   age INT,
  15.   occupation VARCHAR(255),
  16.   affiliation VARCHAR(255)
  17. );
  18.  
  19. -- Create the Hobbies table
  20. CREATE TABLE Hobbies (
  21.   hobby_id INT PRIMARY KEY,
  22.   character_id INT,
  23.   hobby VARCHAR(255),
  24.   FOREIGN KEY (character_id) REFERENCES Characters (character_id)
  25. );
  26.  
  27. -- Create the Antagonists table
  28. CREATE TABLE Antagonists (
  29.   antagonist_id INT PRIMARY KEY,
  30.   name VARCHAR(255),
  31.   rank_strength INT,
  32.   skills VARCHAR(255)
  33. );
  34.  
  35. -- Inserting data into the Characters table
  36. INSERT INTO Characters (character_id, name, age, occupation, affiliation)
  37. VALUES
  38.   (1, 'Monkey D. Luffy', 19, 'Pirate', 'Straw Hat Pirates'),
  39.   (2, 'Roronoa Zoro', 21, 'Swordsman', 'Straw Hat Pirates'),
  40.   (3, 'Nami', 20, 'Navigator', 'Straw Hat Pirates'),
  41.   (4, 'Usopp', 19, 'Sniper', 'Straw Hat Pirates'),
  42.   (5, 'Sanji', 21, 'Chef', 'Straw Hat Pirates'),
  43.   (6, 'Tony Tony Chopper', 17, 'Doctor', 'Straw Hat Pirates'),
  44.   (7, 'Nico Robin', 30, 'Archaeologist', 'Straw Hat Pirates'),
  45.   (8, 'Franky', 36, 'Shipwright', 'Straw Hat Pirates'),
  46.   (9, 'Brook', 90, 'Musician', 'Straw Hat Pirates');
  47.  
  48. -- Inserting data into the Hobbies table
  49. INSERT INTO Hobbies (hobby_id, character_id, hobby)
  50. VALUES
  51.   (1, 1, 'Eating meat and exploring'),
  52.   (2, 2, 'Swordsmanship and training'),
  53.   (3, 3, 'Navigating and studying maps'),
  54.   (4, 4, 'Inventing and storytelling'),
  55.   (5, 5, 'Cooking and flirting'),
  56.   (6, 6, 'Healing and exploring medical advancements'),
  57.   (7, 7, 'Reading and deciphering poneglyphs'),
  58.   (8, 8, 'Building ships and playing cola-powered instruments'),
  59.   (9, 9, 'Playing music and reminiscing about the past');
  60.  
  61. -- Inserting data into the Antagonists table
  62. INSERT INTO Antagonists (antagonist_id, name, rank_strength, skills)
  63. VALUES
  64.   (1, 'Monkey D. Dragon', 100, 'Revolutionary leader'),
  65.   (2, 'Blackbeard', 90, 'Yami Yami no Mi and Gura Gura no Mi user'),
  66.   (3, 'Kaido', 95, 'Dragon Zoan form and immense physical strength'),
  67.   (4, 'Big Mom', 92, 'Soru Soru no Mi user and powerful Haki'),
  68.   (5, 'Akainu', 97, 'Magma Magma no Mi user and strong Busoshoku Haki');
  69.  
  70.  
  71. -------------------------------------------------------------------------------------
  72.  
  73. -- Perform the join query
  74. SELECT C.name, C.age, H.hobby, A.name AS antagonist_name
  75. FROM Characters AS C
  76. INNER JOIN Hobbies AS H ON C.character_id = H.character_id
  77. INNER JOIN Antagonists AS A ON C.character_id = A.antagonist_id
  78. WHERE A.rank_strength >= 95;
Add Comment
Please, Sign In to add comment