Skip to content

Instantly share code, notes, and snippets.

@sohamkamani
Last active October 12, 2023 19:01
Show Gist options
  • Save sohamkamani/c6820c3edd7608afb085763a33877edb to your computer and use it in GitHub Desktop.
Save sohamkamani/c6820c3edd7608afb085763a33877edb to your computer and use it in GitHub Desktop.

Revisions

  1. sohamkamani revised this gist Jan 12, 2023. No changes.
  2. sohamkamani created this gist Jan 12, 2023.
    68 changes: 68 additions & 0 deletions create_tables.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    CREATE TABLE books (
    bookid serial PRIMARY KEY,
    title text,
    author text,
    published date,
    stock int
    );

    INSERT INTO
    books (bookid, title, author, published, stock)
    VALUES
    (
    1,
    'Scion of Ikshvaku',
    'Amish Tripathi',
    '06-22-2015',
    2
    ),
    (
    2,
    'The Lost Symbol',
    'Dan Brown',
    '07-22-2010',
    3
    ),
    (
    3,
    'Who Will Cry When You Die?',
    'Robin Sharma',
    '06-15-2006',
    4
    ),
    (4, 'Inferno', 'Dan Brown', '05-05-2014', 3),
    (
    5,
    'The Fault in our Stars',
    'John Green',
    '01-03-2015',
    3
    );

    CREATE TABLE members (
    memberid serial PRIMARY KEY,
    firstname text,
    lastname text
    );

    INSERT INTO
    members (firstname, lastname)
    VALUES
    ('Mike', 'Willis'),
    ('Ellen', 'Horton'),
    ('John', 'Doe');

    CREATE TABLE borrowings (
    bookid int,
    memberid int,
    returndate date
    );

    INSERT INTO
    borrowings (bookid, memberid, returndate)
    VALUES
    (1, 3, '2022-03-19'),
    (2, 1, '2022-03-23'),
    (3, 3, '2022-03-30'),
    (2, 2, '2022-04-19'),
    (4, 2, '2022-04-19');