| Book Id | Title | Author | Publication Year | Genre | Target Age | Isbn |
|---|---|---|---|---|---|---|
| 5 | Where the Wild Things Are | Maurice Sendak | 1963 | Fiction | 4-8 | 9780064431781 |
| 1 | Charlotte's Web | E.B. White | 1952 | Fiction | 8-12 | 9780064400558 |
| 3101 | The Lion, the Witch and the Wardrobe | C.S. Lewis | 1950 | Fantasy | 8-12 | 8888888888888 |
| 2 | The Cat in the Hat | Dr. Seuss | 1957 | Fiction | 4-8 | 9780394800011 |
| 3 | Winnie-the-Pooh | A.A. Milne | 1926 | Fiction | 6-10 | 9780142404676 |
Look in the controllers/pgsql/crud-demo.js and models/pgsql.js for how the SELECT, INSERT, UPDATE, and DELETE were done.
-- TO MAKE SAMPLE DATABASE AND TABLE
-- Create the database
CREATE DATABASE sample;
-- Create the books table
CREATE TABLE books (
book_id SERIAL PRIMARY KEY,
title VARCHAR(100) NOT NULL,
author VARCHAR(100) NOT NULL,
publication_year INTEGER NOT NULL,
genre VARCHAR(50),
target_age VARCHAR(20),
isbn VARCHAR(13)
);
-- Insert 5 famous children's books published before 1968
INSERT INTO books (title, author, publication_year, genre, target_age, isbn) VALUES
('Charlotte''s Web', 'E.B. White', 1952, 'Fiction', '8-12', '9780064400558'),
('The Cat in the Hat', 'Dr. Seuss', 1957, 'Fiction', '4-8', '9780394800011'),
('Winnie-the-Pooh', 'A.A. Milne', 1926, 'Fiction', '6-10', '9780142404676'),
('The Lion, the Witch and the Wardrobe', 'C.S. Lewis', 1950, 'Fantasy', '8-12', '9780064404990'),
('Where the Wild Things Are', 'Maurice Sendak', 1963, 'Fiction', '4-8', '9780064431781');
-- Create authorized user
CREATE USER sample WITH PASSWORD 'dragonbone#R9';
GRANT CONNECT ON DATABASE sample TO sample;
GRANT SELECT, INSERT, UPDATE, DELETE ON books TO sample;
GRANT USAGE ON SEQUENCE books_book_id_seq TO sample;