anotheruser15564654

data sql population

Nov 7th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. -- Insert authors
  2. INSERT INTO authors (id, name) VALUES (1, 'Harper Lee');
  3. INSERT INTO authors (id, name) VALUES (2, 'George Orwell');
  4. INSERT INTO authors (id, name) VALUES (3, 'F. Scott Fitzgerald');
  5. INSERT INTO authors (id, name) VALUES (4, 'J.K. Rowling');
  6. INSERT INTO authors (id, name) VALUES (5, 'Jane Austen');
  7.  
  8. -- Insert books
  9. INSERT INTO books (title, author_id, price) VALUES ('To Kill a Mockingbird', 1, 15);
  10. INSERT INTO books (title, author_id, price) VALUES ('Go Set a Watchman', 1, 20);
  11. INSERT INTO books (title, author_id, price) VALUES ('1984', 2, 20);
  12. INSERT INTO books (title, author_id, price) VALUES ('Animal Farm', 2, 12);
  13. INSERT INTO books (title, author_id, price) VALUES ('The Great Gatsby', 3, 25);
  14. INSERT INTO books (title, author_id, price) VALUES ('Tender Is the Night', 3, 22);
  15. INSERT INTO books (title, author_id, price) VALUES ('Harry Potter and the Sorcerer''s Stone', 4, 30);
  16. INSERT INTO books (title, author_id, price) VALUES ('Harry Potter and the Chamber of Secrets', 4, 25);
  17. INSERT INTO books (title, author_id, price) VALUES ('Pride and Prejudice', 5, 18);
  18. INSERT INTO books (title, author_id, price) VALUES ('Sense and Sensibility', 5, 16);
  19. INSERT INTO books (title, author_id, price) VALUES ('Emma', 5, 19);
  20. INSERT INTO books (title, author_id, price) VALUES ('This Side of Paradise', 3, 18); -- Additional book for F. Scott Fitzgerald
  21. INSERT INTO books (title, author_id, price) VALUES ('Harry Potter and the Prisoner of Azkaban', 4, 27); -- Additional book for J.K. Rowling
  22.  
  23. INSERT INTO categories (category) VALUES ('FANTASY');
  24. INSERT INTO categories (category) VALUES ('FICTION');
  25.  
  26. -- This query populates AUTHOR_BOOK_MAPPING (which is join table) by associating authors with their corresponding books.
  27. -- Following should be managed by JPA, meaning JPA should create join table, not this script
  28. --INSERT INTO AUTHOR_BOOK_MAPPING (author_id, book_id)
  29. --SELECT a.id, b.id
  30. --FROM authors a
  31. --JOIN books b ON a.id = b.author_id;
  32.  
  33. -- Insert customers POSTPONED
  34. --INSERT INTO customers (name, email) VALUES
  35. --('John Doe', '[email protected]'),
  36. --('Jane Smith', '[email protected]'),
  37. --('Robert Brown', '[email protected]'),
  38. --('Emily Davis', '[email protected]'),
  39. --('Michael Wilson', '[email protected]'),
  40. --('Sarah Johnson', '[email protected]'),
  41. --('David Taylor', '[email protected]'),
  42. --('Laura Martinez', '[email protected]'),
  43. --('James Anderson', '[email protected]'),
  44. --('Linda Thompson', '[email protected]');
  45.  
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment