SQL CRUD Lab

Lab Objectives

  • Practice using SELECT UPDATE REMOVE and INSERT

Practice

In small groups, use PgAdmin to create, update, remove, and query some records for the Library database we created yesterday. There are some required activities below, but feel free to experiment with your database! If you ever feel that you need a fresh start for your database, reach out to your instructors.

Add Books to the Library and Create Library Patrons

  1. Use INSERT to create at least 5 patrons for your library (these can be real, or fake people).
  2. Use INSERT to create at least 10 books in your library. You could have multiple copies of some books, but make sure you have at least 3 unique book titles, and 3 unique authors. (books can also be real, or fake)

When creating records, make sure each record has information in all the database columns!

Check Out Books

  1. Use UPDATE to add a patron to at least 4 of your books (indicating that the book has been checked out by that patron). Make sure that at least 2 different patrons have checked out a book.

Remove Old Books

  1. Occasionally, libraries need to pull books out of circulation (perhaps someone wrote in the margins, or the book has too much wear and tear). Use REMOVE to delete the 3 oldest books in the library (the three you created first).

Query for Available and Unavailable Books

  1. Use SELECT and WHERE to return the title and author of all books that are not checked out.
  2. Use SELECT and WHERE to return the title and author of all books that are checked out.
  3. For each patron, use SELECT and WHERE to return the title of the books each patron has checked out.

Exit Ticket

Send a slack message to your instructors with the SELECT queries you created in the last section above.

Lesson Search Results

Showing top 10 results