Skip to content

Instantly share code, notes, and snippets.

@utkarshsingh99
Created April 17, 2024 14:31
Show Gist options
  • Save utkarshsingh99/e9a8c0a5c8fb8d5fc5973370c0384413 to your computer and use it in GitHub Desktop.
Save utkarshsingh99/e9a8c0a5c8fb8d5fc5973370c0384413 to your computer and use it in GitHub Desktop.
CREATE TABLE authors (
author_id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
birth_date DATE
);
CREATE TABLE books (
book_id INT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
publication_year INT,
author_id INT,
FOREIGN KEY (author_id) REFERENCES authors(author_id)
);
CREATE TABLE patrons (
patron_id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255)
);
CREATE TABLE book_checkouts (
checkout_id INT PRIMARY KEY,
book_id INT,
patron_id INT,
checkout_date DATE,
return_date DATE,
FOREIGN KEY (book_id) REFERENCES books(book_id),
FOREIGN KEY (patron_id) REFERENCES patrons(patron_id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment