VSZM

BOOK-AUTHOR SQL Interview Questions

Jan 15th, 2026 (edited)
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.83 KB | None | 0 0
  1. CREATE TABLE BOOK (
  2.     id INT PRIMARY KEY,
  3.     title VARCHAR(255),
  4.     publication_year INT,
  5.     genre VARCHAR(255),
  6.     ISBN VARCHAR(255)
  7. );
  8.  
  9. CREATE TABLE AUTHOR (
  10.     id INT PRIMARY KEY,
  11.     name VARCHAR(255),
  12.     birth_date DATE
  13. );
  14.  
  15. CREATE TABLE BOOK_AUTHOR (
  16.     book_id INT,
  17.     author_id INT,
  18.     PRIMARY KEY (book_id, author_id),
  19.     FOREIGN KEY (book_id) REFERENCES BOOK(id),
  20.     FOREIGN KEY (author_id) REFERENCES AUTHOR(id)
  21. );
  22.  
  23. /**
  24. TASKS
  25.  
  26.  
  27. When was 'Pebble in the sky' published?
  28.  
  29. Who was the author of the book titled 'Pebble in the sky' ?
  30.  
  31. Show how many books each genre has!
  32.  
  33. Which author has the most books?
  34.  
  35. What is the title of the book that was republished the most amount of times?
  36.  
  37. Design a query to display how many books were written over time, how book writing became more and more popular!
  38. */
Advertisement
Add Comment
Please, Sign In to add comment