8000 GitHub - Blevs/webdb-iii-recitation
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Blevs/webdb-iii-recitation

Repository files navigation

WebDB Recitation III

Today we will be working with multi-table queries on an existing database schema.

Queries

You can connect to a local sqlite database on the command line by running the command sqlite3 dbName.sqlite3. Navigate into the /data directory and open the dev.sqlite3 database this way. You can now run SQL queries against it. (Don’t forget to end your commands with a ;).

You can exit by pressing CTRL-d. View the tables and their schema with the commands .tables and .schema --indent table_name. For a more legible list of a tables columns use PRAGMA table_info('table_name'). To have column names appear in query output run .headers ON and .mode column.

See https://sqlite.org/cli.html for more configuration options.

We will be using the books.db3 in the root of the repository.

Select all books with their publishers

SELECT title, publisher FROM books
JOIN publishers ON publishers.id = books.publisher_id;

Display all reviews with the user name, rating and book title where the rating is above 4

SELECT reviews.rating, users.username, books.title FROM reviews
JOIN users ON users.id = reviews.user_id
JOIN books ON books.id = reviews.book_id
WHERE reviews.rating > 4;

Display all books written by author 6 with the book titles and author names

SELECT books.title, authors.name FROM books_authors
JOIN books ON books.id = books_authors.author_id
JOIN authors ON authors.id = books_authors.book_id;

API

Write helpers and crud routes for owners and pets, with the ability to get all pets belonging to a specific owner.

Schema

owners

nametypenotnullpk
idintegeryesyes
namevarchar(255)yes
emailvarchar(255)yes

species

nametypenotnullpk
idintegeryesyes
specievarchar(255)yes

pets

nametypenot nullpkfk
idintegeryesyes
namevarchar(255)yes
ageintegeryes
owner_idintegeryesowners.id
care_instructionstext
species_idintegeryesspecies.id

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0