Skip to content

Commit

Permalink
fix: Enhance SQL Scripts🫸🌀✏️📗🐧🐳⬆
Browse files Browse the repository at this point in the history
  • Loading branch information
hendisantika committed Nov 1, 2024
1 parent 55fbbb4 commit 3fe1482
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE TABLE BookInstances (
CREATE TABLE book_instances (
instance_id bigserial PRIMARY KEY,
book_id INT REFERENCES Books(book_id),
book_id BIGINT REFERENCES Books(book_id),
status VARCHAR(20) CHECK (status IN ('available', 'checked_out', 'reserved')) NOT NULL,
due_date DATE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE Checkouts (
checkout_id bigserial PRIMARY KEY,
user_id INT REFERENCES Users(user_id),
instance_id INT REFERENCES BookInstances(instance_id),
user_id BIGINT REFERENCES Users(user_id),
instance_id BIGINT REFERENCES book_instances(instance_id),
checkout_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
return_date TIMESTAMP
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ INSERT INTO Books (title, author, isbn, published_date, genre) VALUES
('1984', 'George Orwell', '9780451524935', '1949-06-08', 'Dystopian');

-- Insert Book Instances
INSERT INTO BookInstances (book_id, status, due_date) VALUES
INSERT INTO book_instances (book_id, status, due_date) VALUES
(1, 'available', NULL),
(1, 'checked_out', '2024-07-15'),
(2, 'available', NULL),
Expand Down

0 comments on commit 3fe1482

Please sign in to comment.