parent
c7459758af
commit
f832c839fd
@ -0,0 +1,105 @@
|
||||

|
||||
|
||||
---
|
||||
Title: Airplanes & Airports <br>
|
||||
Type: Lab <br>
|
||||
Created By: Matt Huntington<br>
|
||||
Modified By: Jerrica Bobadilla
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create a new database called `flights`, connect to it, and run the following code (given to you in the `flights.sql` file):
|
||||
- Note: You can run this .sql file using `psql <db_name> -f <path_to_file>`
|
||||
|
||||
```sql
|
||||
CREATE TABLE airlines (
|
||||
id int,
|
||||
name varchar(255) DEFAULT NULL,
|
||||
alias varchar(255) DEFAULT NULL,
|
||||
iata varchar(255) DEFAULT NULL,
|
||||
icao varchar(255) DEFAULT NULL,
|
||||
callsign varchar(255) DEFAULT NULL,
|
||||
country varchar(255) DEFAULT NULL,
|
||||
active varchar(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE airports (
|
||||
id int,
|
||||
name varchar(255) DEFAULT NULL,
|
||||
city varchar(255) DEFAULT NULL,
|
||||
country varchar(255) DEFAULT NULL,
|
||||
iata_faa varchar(255) DEFAULT NULL,
|
||||
icao varchar(255) DEFAULT NULL,
|
||||
latitude varchar(255) DEFAULT NULL,
|
||||
longitude varchar(255) DEFAULT NULL,
|
||||
altitude varchar(255) DEFAULT NULL,
|
||||
utc_offset varchar(255) DEFAULT NULL,
|
||||
dst varchar(255) DEFAULT NULL,
|
||||
tz varchar(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE routes (
|
||||
airline_code varchar(255) DEFAULT NULL,
|
||||
airline_id int DEFAULT NULL,
|
||||
origin_code varchar(255) DEFAULT NULL,
|
||||
origin_id int DEFAULT NULL,
|
||||
dest_code varchar(255) DEFAULT NULL,
|
||||
dest_id int DEFAULT NULL,
|
||||
codeshare varchar(255) DEFAULT NULL,
|
||||
stops int DEFAULT NULL,
|
||||
equipment varchar(255) DEFAULT NULL
|
||||
);
|
||||
```
|
||||
1. In terminal, connect to your `flights` database
|
||||
1. Once inside the psql database (you'll know you're in the right one if your terminal says `flights=#`), run the following lines individually
|
||||
|
||||
```
|
||||
\copy routes FROM 'routes.csv' DELIMITER ',' CSV
|
||||
```
|
||||
- You should get back `COPY 67663` if you were successful
|
||||
|
||||
```
|
||||
\copy airports FROM 'airports.csv' DELIMITER ',' CSV
|
||||
```
|
||||
- You should get back `COPY 8107` if you were successful
|
||||
|
||||
```
|
||||
\copy airlines FROM 'airlines.csv' DELIMITER ',' CSV
|
||||
```
|
||||
- You should get back `COPY 6048` if you were successful
|
||||
|
||||
1. You should now have seeded three tables with flight data!
|
||||
|
||||
## Activity
|
||||
|
||||
> Our **main goal is to find out how many flights go from NYC to Paris.**
|
||||
|
||||
### Hints
|
||||
|
||||
- The routes table has a column called `origin_id` and another called `dest_id`. These map to the `id` column in the airport table. Think about how to treat the `id`s as foreign keys.
|
||||
- You're going to have to use the airports table twice in the same SQL statement. In order to tell which airport is the `destination` and which is the `origin`, you're going to have to temporarily rename the airports table like so:
|
||||
|
||||
```sql
|
||||
/* note that once you rename a table, you MUST refer to it by its new name */
|
||||
SELECT * FROM airports AS origin WHERE origin.city = 'New York';
|
||||
/* later on in the SQL statement, when dealing with the destination, you should do the same for airports AS destination */
|
||||
```
|
||||
- Note that you'll only need to use the routes and airports tables
|
||||
- Think about using aggregation and inner joins
|
||||
|
||||
### Steps to think about
|
||||
|
||||
1. Find all airports that originate from New York
|
||||
1. Find all destination airports in Paris
|
||||
1. Find out how many routes originate from New York
|
||||
1. Find out how many routes have destinations in Paris
|
||||
1. Try to decide which statements are necessary and find how to combine them to find out how many routes originate from New York and land in Paris!
|
||||
|
||||
## Stretch Goals
|
||||
|
||||
- Do this so that just the number appears as the result of only one SQL statement
|
||||
- Which airlines travel from NYC to Paris?
|
||||
- Find all the flights that leave NYC. Give a list of how many go to each destination city.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
CREATE TABLE airlines (
|
||||
id int,
|
||||
name varchar(255) DEFAULT NULL,
|
||||
alias varchar(255) DEFAULT NULL,
|
||||
iata varchar(255) DEFAULT NULL,
|
||||
icao varchar(255) DEFAULT NULL,
|
||||
callsign varchar(255) DEFAULT NULL,
|
||||
country varchar(255) DEFAULT NULL,
|
||||
active varchar(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE airports (
|
||||
id int,
|
||||
name varchar(255) DEFAULT NULL,
|
||||
city varchar(255) DEFAULT NULL,
|
||||
country varchar(255) DEFAULT NULL,
|
||||
iata_faa varchar(255) DEFAULT NULL,
|
||||
icao varchar(255) DEFAULT NULL,
|
||||
latitude varchar(255) DEFAULT NULL,
|
||||
longitude varchar(255) DEFAULT NULL,
|
||||
altitude varchar(255) DEFAULT NULL,
|
||||
utc_offset varchar(255) DEFAULT NULL,
|
||||
dst varchar(255) DEFAULT NULL,
|
||||
tz varchar(255) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE routes (
|
||||
airline_code varchar(255) DEFAULT NULL,
|
||||
airline_id int DEFAULT NULL,
|
||||
origin_code varchar(255) DEFAULT NULL,
|
||||
origin_id int DEFAULT NULL,
|
||||
dest_code varchar(255) DEFAULT NULL,
|
||||
dest_id int DEFAULT NULL,
|
||||
codeshare varchar(255) DEFAULT NULL,
|
||||
stops int DEFAULT NULL,
|
||||
equipment varchar(255) DEFAULT NULL
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
routes
|
||||
INNER JOIN
|
||||
airports
|
||||
AS
|
||||
origin
|
||||
ON
|
||||
origin.iata_faa = routes.origin_code
|
||||
INNER JOIN
|
||||
airports
|
||||
AS
|
||||
destination
|
||||
ON
|
||||
destination.iata_faa = routes.dest_code
|
||||
WHERE
|
||||
origin.city = 'New York'
|
||||
AND
|
||||
destination.city = 'Paris';
|
||||
@ -0,0 +1,27 @@
|
||||
-- Find all airports that originate from New York
|
||||
|
||||
SELECT * FROM airports WHERE city = 'New York';
|
||||
|
||||
|
||||
|
||||
-- Find all destination airports in Paris
|
||||
|
||||
SELECT * FROM airports WHERE city = 'Paris';
|
||||
|
||||
|
||||
|
||||
-- Find out how many routes originate from New York
|
||||
|
||||
SELECT COUNT(*) FROM routes JOIN airports AS origin ON origin.iata_faa = routes.origin_code WHERE origin.city = 'New York';
|
||||
|
||||
|
||||
|
||||
-- Find out how many routes have destinations in Paris
|
||||
|
||||
SELECT COUNT(*) FROM routes JOIN airports AS destination ON destination.iata_faa = routes.dest_code WHERE destination.city = 'Paris';
|
||||
|
||||
|
||||
|
||||
-- Try to decide which statements are necessary and find how to combine them to find out how many routes originate from New York and land in Paris!
|
||||
|
||||
SELECT COUNT(*) FROM routes JOIN airports AS origin ON origin.iata_faa = routes.origin_code JOIN airports AS destination ON destination.iata_faa = routes.dest_code WHERE origin.city = 'New York' AND destination.city = 'Paris';
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||

|
||||
|
||||
---
|
||||
Title: Computers & Televisions <br>
|
||||
Type: Lab <br>
|
||||
Creator: Thom Page <br>
|
||||
Adapted By: Jerrica Bobadilla
|
||||
|
||||
---
|
||||
|
||||
# :computer: Computers & Televisions :tv:
|
||||
|
||||
For today's morning lab, you'll be getting practice with the SQL commands you just learned.
|
||||
|
||||
_NOTE!_ To create a new postgres database without connecting to psql, in terminal bash just run `createdb [databasename]` where [databasename] is whatever you want to name your new database.
|
||||
|
||||
### Activity
|
||||
|
||||
1. Start by working in the `computers.sql` file and follow the directions outlined there
|
||||
1. Move onto the `televisions.sql` file and follow the directions outlined there
|
||||
|
||||
##### :red_circle: How to run .sql files in terminal:
|
||||
|
||||
- To run the .sql files, use the command: `psql -f sql_file_name.sql database_name`
|
||||
- For example: `psql -f computers.sql sql_lab`
|
||||
|
||||
### Hungry for More?
|
||||
|
||||
If you finish both files, try out the [realty lab](./realty)!
|
||||
@ -0,0 +1,78 @@
|
||||
-- Open up psql and create a sql_lab database if you haven't already done so.
|
||||
-- If you already have a sql_lab database, no need to create it again.
|
||||
|
||||
-- Write SQL commands under the prompts below, and run the file to get results.
|
||||
|
||||
-- In case there is already a computers table, drop it
|
||||
|
||||
-- Create a computers table
|
||||
|
||||
|
||||
--###############
|
||||
--I added the delete command at the beginning when I want to rerun instead of having to enter commands manually. while debugging. But keep commented out if running whole thing to test.
|
||||
|
||||
DROP DATABASE computers;
|
||||
|
||||
---##############
|
||||
|
||||
CREATE DATABASE computers;
|
||||
|
||||
-- The table should have id, make, model, cpu_speed, memory_size,price, release_date, photo_url, storage_amount, number_usb_ports, number_firewire_ports, number_thunderbolt_ports);
|
||||
|
||||
\connect computers;
|
||||
|
||||
CREATE TABLE computers(id serial, make varchar(20), model varchar(20), cpu_speed int, memory_size int, price int, release_date timestamp, photo_url varchar(140), storage_amount int, number_usb_ports int, number_firewire_ports int, number_thunderbolt_ports int);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Insert 4 computers into the computers table
|
||||
|
||||
INSERT INTO computers(make, model, cpu_speed, memory_size, price, photo_url, storage_amount, number_usb_ports, number_firewire_ports, number_thunderbolt_ports) VALUES ('apple', 'desktop', 2200, 16, 2399, 'www.photo.com, 500', 8, 4, 2, 2);
|
||||
|
||||
INSERT INTO computers(make, model, cpu_speed, memory_size, price) VALUES ('pc', 'laptop', 220, 8, 1250);
|
||||
|
||||
INSERT INTO computers(make, model, price, release_date) VALUES ('pc', 'pixelbook', 677, '1981-12-01 22:33:44');
|
||||
|
||||
--yyyy-mm-dd hh:mm:ss
|
||||
|
||||
INSERT INTO computers(make, model, price) VALUES ('apple', 'macbook pro', 3000);
|
||||
|
||||
|
||||
|
||||
-- Select all entries from the computers table
|
||||
|
||||
|
||||
--run here to show homework up to this point. and comment out this select all to run first part. otherwise keep it commented out.
|
||||
|
||||
-- SELECT * FROM computers;
|
||||
|
||||
|
||||
-- HUNGRY FOR MORE?
|
||||
|
||||
-- Look at this afternoon's instructor notes and read on altering tables before attempting below
|
||||
|
||||
-- Alter the computers_models, removing the storage_amount column
|
||||
-- and add storage_type and storage_size columns
|
||||
|
||||
|
||||
ALTER TABLE computers DROP COLUMN storage_amount;
|
||||
ALTER TABLE computers ADD COLUMN storage_type varchar(50);
|
||||
ALTER TABLE computers ADD COLUMN storage_size int;
|
||||
|
||||
|
||||
|
||||
-- ########NOTES#######
|
||||
--students will need to comment out first command and create table commands if they want to rerun code to debug. like for example if there are syntax errors.
|
||||
--they could get errors ERROR: relation "computers" already exists
|
||||
--another example ERROR: INSERT has more target columns than expressions
|
||||
|
||||
SELECT * FROM computers;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
-- Open up psql and create a sql_lab database if you haven't already done so.
|
||||
-- If you already have a sql_lab database, no need to create it again.
|
||||
|
||||
-- Write SQL commands under the prompts below, and run the file to get results.
|
||||
|
||||
-- In case there is already a televisions table, drop it
|
||||
|
||||
-- DROP DATABASE televisions;
|
||||
|
||||
|
||||
|
||||
CREATE DATABASE televisions;
|
||||
|
||||
\connect televisions;
|
||||
|
||||
-- Create a televisions table
|
||||
-- The table should have id, model_name, screen_size, resolution,
|
||||
-- price, release_date, photo_url
|
||||
|
||||
CREATE TABLE televisions(id serial, model_name varchar(20), screen_size int, resolution int, price int, release_date int, photo_url varchar(140));
|
||||
|
||||
-- Insert 4 televisions into the tv_models table
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('samsung', 55, 1080, 1999, 'www.photo1.com');
|
||||
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('samsung', 55, 1080, 1999,'www.photo2.com');
|
||||
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('sony', 32, 1080, 1999, 'www.photo3.com');
|
||||
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('lg', 27, 1080, 1999, 'www.photo4.com');
|
||||
|
||||
-- Select all entries from the tv_models table
|
||||
|
||||
|
||||
-- HUNGRY FOR MORE?
|
||||
-- Look at this afternoon's instructor notes and read on altering tables before attempting below
|
||||
|
||||
-- Alter the tv_models, removing the resolution column
|
||||
-- and add vertical_resolution and horizontal_resolution columns
|
||||
|
||||
ALTER TABLE televisions DROP COLUMN resolution;
|
||||
ALTER TABLE televisions ADD COLUMN vertical_resolution int;
|
||||
ALTER TABLE televisions ADD COLUMN horizontal_resolution int;
|
||||
|
||||
|
||||
|
||||
SELECT * FROM televisions;
|
||||
@ -0,0 +1,29 @@
|
||||

|
||||
|
||||
---
|
||||
Title: Computers & Televisions <br>
|
||||
Type: Lab <br>
|
||||
Creator: Thom Page <br>
|
||||
Adapted By: Jerrica Bobadilla
|
||||
|
||||
---
|
||||
|
||||
# :computer: Computers & Televisions :tv:
|
||||
|
||||
For today's morning lab, you'll be getting practice with the SQL commands you just learned.
|
||||
|
||||
_NOTE!_ To create a new postgres database without connecting to psql, in terminal bash just run `createdb [databasename]` where [databasename] is whatever you want to name your new database.
|
||||
|
||||
### Activity
|
||||
|
||||
1. Start by working in the `computers.sql` file and follow the directions outlined there
|
||||
1. Move onto the `televisions.sql` file and follow the directions outlined there
|
||||
|
||||
##### :red_circle: How to run .sql files in terminal:
|
||||
|
||||
- To run the .sql files, use the command: `psql -f sql_file_name.sql database_name`
|
||||
- For example: `psql -f computers.sql sql_lab`
|
||||
|
||||
### Hungry for More?
|
||||
|
||||
If you finish both files, try out the [realty lab](./realty)!
|
||||
@ -0,0 +1,29 @@
|
||||

|
||||
|
||||
---
|
||||
Title: Computers & Televisions <br>
|
||||
Type: Lab <br>
|
||||
Creator: Thom Page <br>
|
||||
Adapted By: Jerrica Bobadilla
|
||||
|
||||
---
|
||||
|
||||
# :computer: Computers & Televisions :tv:
|
||||
|
||||
For today's morning lab, you'll be getting practice with the SQL commands you just learned.
|
||||
|
||||
_NOTE!_ To create a new postgres database without connecting to psql, in terminal bash just run `createdb [databasename]` where [databasename] is whatever you want to name your new database.
|
||||
|
||||
### Activity
|
||||
|
||||
1. Start by working in the `computers.sql` file and follow the directions outlined there
|
||||
1. Move onto the `televisions.sql` file and follow the directions outlined there
|
||||
|
||||
##### :red_circle: How to run .sql files in terminal:
|
||||
|
||||
- To run the .sql files, use the command: `psql -f sql_file_name.sql database_name`
|
||||
- For example: `psql -f computers.sql sql_lab`
|
||||
|
||||
### Hungry for More?
|
||||
|
||||
If you finish both files, try out the [realty lab](./realty)!
|
||||
@ -0,0 +1,63 @@
|
||||
-- Open up psql and create a sql_lab database if you haven't already done so.
|
||||
-- If you already have a sql_lab database, no need to create it again.
|
||||
|
||||
-- Create computers database
|
||||
CREATE DATABASE computers;
|
||||
-- connect to computers database
|
||||
\connect computers;
|
||||
|
||||
-- Write SQL commands under the prompts below, and run the file to get results:
|
||||
|
||||
-- 1. In case there is already a computers table, drop it
|
||||
|
||||
DROP TABLE computers;
|
||||
|
||||
-- *** FYI --- I added the delete command at the beginning when I want to rerun instead of having to enter commands manually. while debugging. But keep commented out if running whole thing to test.
|
||||
|
||||
-- 2. Create a computers table. The table should have id, make, model, cpu_speed, memory_size,price, release_date, photo_url, storage_amount, number_usb_ports, number_firewire_ports, number_thunderbolt_ports, number_thunderbolt_ports);
|
||||
|
||||
|
||||
CREATE TABLE computers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
make VARCHAR(255) NOT NULL,
|
||||
model VARCHAR(255) NOT NULL,
|
||||
cpu_speed FLOAT NOT NULL,
|
||||
memory_size INTEGER NOT NULL,
|
||||
price NUMERIC(10,2) NOT NULL,
|
||||
release_date DATE NOT NULL,
|
||||
photo_url VARCHAR(255) NOT NULL,
|
||||
storage_amount INTEGER NOT NULL,
|
||||
number_usb_ports INTEGER NOT NULL,
|
||||
number_firewire_ports INTEGER NOT NULL,
|
||||
number_thunderbolt_ports INTEGER NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
||||
-- 3. Insert 4 computers into the computers table
|
||||
|
||||
|
||||
INSERT INTO computers (make, model, cpu_speed, memory_size, price, release_date, photo_url, storage_amount, number_usb_ports, number_firewire_ports, number_thunderbolt_ports)
|
||||
VALUES
|
||||
('Apple', 'MacBook Air', 1.1, 8, 999.99, '2020-03-18', 'https://example.com/macbook-air.jpg', 256, 2, 0, 2),
|
||||
('Dell', 'Inspiron 15', 2.4, 16, 799.99, '2020-02-25', 'https://example.com/inspiron-15.jpg', 512, 3, 1, 0),
|
||||
('Lenovo', 'ThinkPad X1 Carbon', 1.8, 16, 1299.99, '2020-01-15', 'https://example.com/thinkpad-x1-carbon.jpg', 512, 2, 1, 1),
|
||||
('HP', 'Spectre x360', 2.2, 16, 1499.99, '2020-05-10', 'https://example.com/spectre-x360.jpg', 1, 3, 1, 1);
|
||||
|
||||
|
||||
|
||||
-- 4. Select all entries from the computers table
|
||||
|
||||
SELECT * FROM computers;
|
||||
|
||||
|
||||
------ HUNGRY FOR MORE? ------
|
||||
|
||||
-- Look at this afternoon's instructor notes and read on altering tables before attempting below:
|
||||
-- 1. Alter the computers_models, removing the storage_amount column
|
||||
ALTER TABLE computers DROP COLUMN storage_amount;
|
||||
-- 2. Add storage_type and storage_size columns
|
||||
ALTER TABLE computers ADD COLUMN storage_type;
|
||||
ALTER TABLE computers ADD COLUMN storage_size;
|
||||
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
-- Open up psql and create a sql_lab database if you haven't already done so.
|
||||
-- If you already have a sql_lab database, no need to create it again.
|
||||
|
||||
-- Write SQL commands under the prompts below, and run the file to get results.
|
||||
|
||||
-- In case there is already a televisions table, drop it
|
||||
|
||||
DROP DATABASE televisions;
|
||||
|
||||
CREATE DATABASE televisions;
|
||||
\connect televisions;
|
||||
|
||||
-- 1. Create a televisions table
|
||||
-- The table should have id, model_name, screen_size, resolution,
|
||||
-- price, release_date, photo_url
|
||||
|
||||
CREATE TABLE televisions(id serial, model_name varchar(20), screen_size int, resolution int, price int, release_date int, photo_url varchar(140));
|
||||
|
||||
-- 2. Insert 4 televisions into the tv_models table
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('samsung', 55, 1080, 1999, 'www.photo1.com');
|
||||
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('samsung', 55, 1080, 1999,'www.photo2.com');
|
||||
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('sony', 32, 1080, 1999, 'www.photo3.com');
|
||||
|
||||
INSERT INTO televisions(model_name, screen_size, resolution, price, photo_url) VALUES ('lg', 27, 1080, 1999, 'www.photo4.com');
|
||||
|
||||
-- 3. Select all entries from the tv_models table
|
||||
|
||||
SELECT * FROM televisions;
|
||||
|
||||
------ HUNGRY FOR MORE? -------
|
||||
-- Look at this afternoon's instructor notes and read on altering tables before attempting below
|
||||
|
||||
-- 1. Alter the tv_models, removing the resolution column
|
||||
|
||||
ALTER TABLE televisions DROP COLUMN resolution;
|
||||
-- 2. Add vertical_resolution and horizontal_resolution columns
|
||||
ALTER TABLE televisions ADD COLUMN vertical_resolution int;
|
||||
ALTER TABLE televisions ADD COLUMN horizontal_resolution int;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SELECT * FROM televisions;
|
||||
@ -0,0 +1,62 @@
|
||||

|
||||
|
||||
---
|
||||
Title: DogGroomerSQL <br>
|
||||
Type: Homework <br>
|
||||
Created By: Hunter Wallen<br>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Setup
|
||||
|
||||
1. Create a new database called `DogGroomer`, connect to it, and run the following code (given to you in the `schema.sql` file inside of the `groomer_seed_data` directory):
|
||||
- Note: You can run this .sql file using `psql <db_name> -f <path_to_file>`
|
||||
|
||||
```sql
|
||||
drop table if exists dogs;
|
||||
drop table if exists owners;
|
||||
drop table if exists groomers;
|
||||
|
||||
create table dogs(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
breed varchar(255) not null,
|
||||
owner integer,
|
||||
groomer integer
|
||||
);
|
||||
|
||||
create table owners(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
groomer integer,
|
||||
dogs integer[]
|
||||
);
|
||||
|
||||
create table groomers(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
rate integer not null,
|
||||
owners integer[],
|
||||
dogs integer[]
|
||||
);
|
||||
```
|
||||
1. In terminal, connect to your `DogGroomer` database
|
||||
1. Once inside the psql database (you'll know you're in the right one if your terminal says `DogGroomer=#`), copy and paste the seed data from `dogs.sql`, `groomers.sql` and `owners.sql` into your terminal.
|
||||
1. Query for `*` in each of the three tables to make sure the data was inputted correctly.
|
||||
|
||||
## Activity
|
||||
|
||||
- In the `answers.sql` file you will find a series of challenges. Below them, type the appropriate SQL command to access the data requested.
|
||||
- You must complete at least 8 of the provided challenges for a completion on this assignment.
|
||||
|
||||
---
|
||||
|
||||
#### Heads Up!
|
||||
|
||||
Some of the Data in the tables is in the form of an array! Check out the [PostgreSQL Docs](https://www.postgresql.org/docs/9.1/arrays.html) about arrays before you start!
|
||||
|
||||
|
||||
#### Hungry For More?
|
||||
|
||||
- Use joins to solve the appropriate questions.
|
||||
@ -0,0 +1,75 @@
|
||||
------------------------------------
|
||||
------------------------------------
|
||||
-- Type the query you use to locate the data requested below the request in this file!
|
||||
|
||||
-- *** Finish at least 8 for a completion of this hw ****
|
||||
------------------------------------
|
||||
------------------------------------
|
||||
|
||||
-- 1. List the names of all of the groomers.
|
||||
|
||||
|
||||
|
||||
-- 2. List the names and breeds of all of the dogs.
|
||||
|
||||
|
||||
|
||||
-- 3. List the names of all of the dogs that are clients of Shawn.
|
||||
|
||||
|
||||
|
||||
|
||||
-- 4. List the name and breed of the first dog in Brandy's list of clients.
|
||||
|
||||
|
||||
|
||||
|
||||
-- 5. List all of the names and breeds of the dogs that are Paxton's groomer's clients. (You may need to do two commands to accomplish this. HFM? Try to figure out how to do it in one.)
|
||||
|
||||
|
||||
|
||||
-- 6. List the average rate for all of the groomers.
|
||||
|
||||
|
||||
|
||||
-- 7. List the number of dogs the two lowest paid groomers are responsible for. (You may need to do two commands to accomplish this. Also, check out cardinality. HFM? Try to figure out how to do it in one.)
|
||||
|
||||
|
||||
|
||||
-- 8. List how many dogs Ahna owns.
|
||||
|
||||
|
||||
|
||||
-- 9. List the two highest paid groomers.
|
||||
|
||||
|
||||
|
||||
-- 10. List the total number of dogs that the two lowest paid groomers care for.
|
||||
|
||||
|
||||
|
||||
-- 11. List the three owners who are willing to pay the most for their dog grooming.
|
||||
|
||||
|
||||
|
||||
-- 12. List the names and breeds of the dogs that belong to the owners who are paying $30 for their grooming.
|
||||
|
||||
|
||||
|
||||
|
||||
---------------
|
||||
-- HUNGRY FOR MORE
|
||||
---------------
|
||||
|
||||
|
||||
-- 13. List the average rate of the two highest paid groomers.
|
||||
|
||||
|
||||
|
||||
-- 14. List the names and breeds of the two lowest paid groomers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
@ -0,0 +1,15 @@
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Fido', 'Pomsky', 1, 4);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Tiny', 'Rotweiller', 2, 1);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Teensy', 'Rotweiller', 2, 1);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Champ', 'Doberman', 3, 2);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Sunshine', 'Lab', 4, 4);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Nero', 'Husky', 5, 2);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Kurt', 'Large Mix', 5, 2);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Jax', 'Large Mix', 6, 3);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Fluffy', 'Wirehaired Pointer', 7, 3);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Brutus', 'Chihuahua', 8, 3);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Jake', 'Labradoodle', 9, 3);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Connor', 'Lab', 10, 5);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Arthur', 'Basset Hound', 10, 5);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Cindy', 'Pit Bull Terrier', 11, 5);
|
||||
INSERT INTO dogs (name, breed, owner, groomer) VALUES ('Angel', 'Austrailian Shephard', 12, 5);
|
||||
@ -0,0 +1,5 @@
|
||||
INSERT INTO groomers (name, rate, owners, dogs) VALUES ('Vicky', 35, '{2}', '{2, 3}');
|
||||
INSERT INTO groomers (name, rate, owners, dogs) VALUES ('Arnold', 25, '{3, 5}', '{4, 6, 7}');
|
||||
INSERT INTO groomers (name, rate, owners, dogs) VALUES ('Shawn', 30, '{6, 7, 8, 9}', '{8, 9, 10, 11}');
|
||||
INSERT INTO groomers (name, rate, owners, dogs) VALUES ('Walt', 50, '{1, 4}', '{1, 5}');
|
||||
INSERT INTO groomers (name, rate, owners, dogs) VALUES ('Eric', 35, '{10, 11, 12}', '{12, 13, 14, 15}');
|
||||
@ -0,0 +1,12 @@
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Jeff', 4, '{1}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Brandy', 1, '{2, 3}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Javi', 2, '{4}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Owen', 4, '{5}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Hunter', 2, '{6, 7}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Nicole', 3, '{8}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Jeffery', 3, '{9}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Jake', 3, '{10}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Paul', 3, '{11}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Ahna', 5, '{12, 13}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Eileen', 5, '{14}');
|
||||
INSERT INTO owners (name, groomer, dogs) VALUES ('Paxton', 5, '{15}');
|
||||
@ -0,0 +1,26 @@
|
||||
drop table if exists dogs;
|
||||
drop table if exists owners;
|
||||
drop table if exists groomers;
|
||||
|
||||
create table dogs(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
breed varchar(255) not null,
|
||||
owner integer,
|
||||
groomer integer
|
||||
);
|
||||
|
||||
create table owners(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
groomer integer,
|
||||
dogs integer[]
|
||||
);
|
||||
|
||||
create table groomers(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
rate integer not null,
|
||||
owners integer[],
|
||||
dogs integer[]
|
||||
);
|
||||
@ -0,0 +1,83 @@
|
||||
------------------------------------
|
||||
------------------------------------
|
||||
-- Type the query you use to locate the data requested below the request in this file!
|
||||
------------------------------------
|
||||
------------------------------------
|
||||
|
||||
-- 1. List the names of all of the groomers.
|
||||
SELECT name FROM groomers;
|
||||
|
||||
|
||||
-- 2. List the names and breeds of all of the dogs.
|
||||
SELECT name, breed FROM dogs;
|
||||
|
||||
|
||||
-- 3. List the names of all of the dogs that are clients of Shawn.
|
||||
SELECT dogs.name FROM dogs, groomers WHERE dogs.groomer=groomers.id AND groomers.name LIKE 'Shawn';
|
||||
|
||||
|
||||
|
||||
-- 4. List the name and breed of the first dog in Walt's list of clients.
|
||||
SELECT dogs.name, dogs.breed FROM dogs, groomers WHERE dogs.id=groomers.dogs[1] AND groomers.name LIKE 'Walt';
|
||||
|
||||
|
||||
|
||||
-- 5. List all of the names and breeds of the dogs that are Paxton's groomer's clients. (You may need to do two commands to accomplish this. HFM? Try to figure out how to do it in one.)
|
||||
SELECT groomer FROM owners WHERE name LIKE 'Paxton';
|
||||
SELECT dogs.name, dogs.breed FROM dogs, groomers WHERE dogs.groomer=groomers.id AND groomers.id=5;
|
||||
|
||||
--or
|
||||
SELECT dogs.name, dogs.breed FROM dogs, owners WHERE dogs.id = ANY (owners.dogs) AND owners.groomer = (SELECT groomers.id FROM owners, groomers WHERE groomers.id=owners.groomer AND owners.name LIKE 'Paxton');
|
||||
|
||||
|
||||
|
||||
-- 6. List the average rate for all of the groomers.
|
||||
SELECT AVG(rate) FROM groomers;
|
||||
|
||||
|
||||
|
||||
-- 7. List the number of dogs the two lowest paid groomers are responsible for. (You may need to do two commands to accomplish this. Also, check out cardinality. HFM? Try to figure out how to do it in one.)
|
||||
SELECT id FROM groomers ORDER BY rate ASC LIMIT 2;
|
||||
SELECT SUM(cardinality(dogs)) FROM groomers WHERE id = 2 OR id = 3;
|
||||
|
||||
|
||||
--or
|
||||
SELECT SUM(cardinality(dogs)) FROM groomers WHERE rate = (SELECT rate FROM groomers ORDER BY rate ASC LIMIT 1) OR rate = (SELECT rate FROM groomers ORDER BY rate ASC OFFSET 1 LIMIT 1);
|
||||
|
||||
|
||||
|
||||
|
||||
-- 8. List how many dogs Ahna owns. (Check out cardinality)
|
||||
SELECT cardinality(dogs) FROM owners WHERE name LIKE 'Ahna';
|
||||
|
||||
|
||||
|
||||
-- 9. List the two highest paid groomers.
|
||||
SELECT name FROM groomers ORDER BY rate DESC LIMIT 2;
|
||||
|
||||
|
||||
-- 10. Who grooms the most dogs?
|
||||
SELECT name FROM groomers WHERE cardinality(dogs) = ( SELECT MAX(cardinality(dogs)) FROM groomers);
|
||||
|
||||
|
||||
-- 11. List the three owners who are willing to pay the most for their dog grooming.
|
||||
SELECT owners.name FROM groomers, owners WHERE owners.groomer=groomers.id ORDER BY groomers.rate DESC LIMIT 3;
|
||||
|
||||
|
||||
|
||||
-- 12. List the names and breeds of the dogs that belong to the owners who are paying $30 for their grooming using only one command.
|
||||
SELECT dogs.name, dogs.breed FROM dogs, owners, groomers WHERE dogs.owner=owners.id AND owners.groomer=groomers.id AND groomers.rate = 30;
|
||||
|
||||
|
||||
|
||||
|
||||
---------------
|
||||
-- HUNGRY FOR MORE
|
||||
---------------
|
||||
|
||||
-- 13. List the average rate of the two highest paid groomers.
|
||||
SELECT AVG(rate) FROM groomers WHERE rate=(SELECT rate FROM groomers ORDER BY rate DESC LIMIT 1) OR rate=(SELECT rate FROM groomers ORDER BY rate DESC OFFSET 1 LIMIT 1);
|
||||
|
||||
|
||||
-- 14. List the names and breeds of the two lowest paid groomers.
|
||||
SELECT dogs.name, dogs.breed FROM dogs, groomers WHERE dogs.id=ANY (groomers.dogs) AND (groomers.rate = (SELECT rate FROM groomers ORDER BY rate ASC LIMIT 1) OR groomers.rate = (SELECT rate FROM groomers ORDER BY rate ASC OFFSET 1 LIMIT 1));
|
||||
@ -0,0 +1,79 @@
|
||||

|
||||
|
||||
# NFL
|
||||
|
||||
---
|
||||
Title: NFL <br>
|
||||
Type: Homework<br>
|
||||
Modified by: Karolin Rafalski, Thom Page <br>
|
||||
Competencies: Basic SQL<br>
|
||||
|
||||
---
|
||||
|
||||
### Schema and seed
|
||||
|
||||
You are provided with a schema file [schema.sql](nfl_seed_data/schema.sql) and two seed files
|
||||
`players.sql`, `teams.sql` that are also in the `nfl_seed_data` folder. Create a new database called `nfl` and use the schema and seed file to populate your database.
|
||||
|
||||
<hr>
|
||||
:red_circle: "Commit: NFL db seeded"
|
||||
<hr>
|
||||
|
||||
|
||||
Record your answers to Step 3 in a file called [nfl.sql](nfl.sql).
|
||||
|
||||
_Challenge_: Complete each part with a single SQL expression. That is
|
||||
possible, but for some queries, it will involve learning how to use compound SQL
|
||||
expressions.
|
||||
|
||||
|
||||
### Queries
|
||||
|
||||
Some queries may require more than one command (i.e. you may need to get information about a team before you can complete a query for players). Test each command in PSQL to make sure it is correct.
|
||||
|
||||
1. List the names of all NFL teams
|
||||
2. List the stadium name and head coach of all NFC teams
|
||||
3. List the head coaches of the AFC South
|
||||
4. The total number of players in the NFL
|
||||
|
||||
<hr>
|
||||
:red_circle: "Commit: NFL queries 1"
|
||||
<hr>
|
||||
|
||||
5. The team names and head coaches of the NFC North and AFC East
|
||||
6. The 50 players with the highest salaries
|
||||
7. The average salary of all NFL players
|
||||
8. The names and positions of players with a salary above 10_000_000
|
||||
|
||||
<hr>
|
||||
:red_circle: "Commit: NFL queries 2"
|
||||
<hr>
|
||||
|
||||
9. The player with the highest salary in the NFL
|
||||
10. The name and position of the first 100 players with the lowest salaries
|
||||
11. The average salary for a DE in the nfl
|
||||
|
||||
<hr>
|
||||
:red_circle: "Commit: NFL queries 3"
|
||||
<hr>
|
||||
|
||||
## Hungry For More
|
||||
|
||||
For these you will need to query two tables at the same time. In order to do some parts you will need to research commands using dot notation that we did not cover in class.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
> The names of all the players on the Buffalo Bills
|
||||
|
||||
```sql
|
||||
SELECT players.name, teams.name
|
||||
FROM players, teams
|
||||
WHERE players.team_id=teams.id AND teams.name LIKE 'Buffalo Bills';
|
||||
```
|
||||
|
||||
13. The total salary of all players on the New York Giants
|
||||
14. The player with the lowest salary on the Green Bay Packers
|
||||
|
||||
<hr>
|
||||
:red_circle: "Commit: NFL - HFM"
|
||||
<hr>
|
||||
@ -0,0 +1,40 @@
|
||||
-- 1. List the names of all NFL teams'
|
||||
|
||||
|
||||
-- 2. List the stadium name and head coach of all NFC teams
|
||||
|
||||
|
||||
-- 3. List the head coaches of the AFC South
|
||||
|
||||
|
||||
-- 4. The total number of players in the NFL
|
||||
|
||||
|
||||
-- 5. The team names and head coaches of the NFC North and AFC East
|
||||
|
||||
|
||||
-- 6. The 50 players with the highest salaries
|
||||
|
||||
|
||||
-- 7. The average salary of all NFL players
|
||||
|
||||
|
||||
-- 8. The names and positions of players with a salary above 10_000_000
|
||||
|
||||
|
||||
-- 9. The player with the highest salary in the NFL
|
||||
|
||||
|
||||
-- 10. The name and position of the first 100 players with the lowest salaries
|
||||
|
||||
|
||||
-- 11. The average salary for a DE in the nfl
|
||||
|
||||
|
||||
-- 12. The names of all the players on the Buffalo Bills
|
||||
|
||||
|
||||
-- 13. The total salary of all players on the New York Giants
|
||||
|
||||
|
||||
-- 14. The player with the lowest salary on the Green Bay Packers
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
drop table if exists players;
|
||||
drop table if exists teams;
|
||||
|
||||
create table teams(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
stadium varchar(255),
|
||||
division varchar(255),
|
||||
conference varchar(255),
|
||||
head_coach varchar(255),
|
||||
active boolean
|
||||
);
|
||||
|
||||
create table players(
|
||||
id serial primary key,
|
||||
name varchar(255) not null,
|
||||
position varchar(255),
|
||||
salary integer,
|
||||
team_id integer references teams
|
||||
);
|
||||
@ -0,0 +1,32 @@
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Buffalo Bills', 'Ralph Wilson Stadium', 'Doug Marrone', 'AFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Miami Dolphins', 'Sun Life Stadium', 'Joe Philbin', 'AFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('New England Patriots', 'Gillette Stadium', 'Bill Belichick', 'AFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('New York Jets', 'MetLife Stadium', 'Rex Ryan', 'AFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Baltimore Ravens', 'M&T Bank Stadium', 'John Harbaugh', 'AFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Cincinnati Bengals', 'Paul Brown Stadium', 'Marvin Lewis', 'AFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Cleveland Browns', 'FirstEnergy Stadium', 'Mike Pettine', 'AFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Pittsburgh Steelers', 'Heinz Field', 'Mike Tomlin', 'AFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Houston Texans', 'NRG Stadium', 'Bill OBrien', 'AFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Indianapolis Colts', 'Lucas Oil Stadium', 'Chuck Pagano', 'AFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Jacksonville Jaguars', 'EverBank Field', 'Gus Bradley', 'AFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Tennessee Titans', 'LP Field', 'Ken Whisenhunt', 'AFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Denver Broncos', 'Sports Authority Field', 'John Fox', 'AFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Kansas City Chiefs', 'Arrowhead Stadium', 'Andy Reid', 'AFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Oakland Raiders', 'O.co Coliseum', 'Tony Sparano', 'AFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('San Diego Chargers', 'Qualcomm Stadium', 'Mike McCoy', 'AFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Dallas Cowboys', 'AT&T Stadium', 'Jason Garrett', 'NFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('New York Giants', 'MetLife Stadium', 'Tom Coughlin', 'NFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Philadelphia Eagles', 'Lincoln Financial Field', 'Chip Kelly', 'NFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Washington Redskins', 'FedExField', 'Jay Gruden', 'NFC', 'East', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Chicago Bears', 'Soldier Field', 'Marc Trestman', 'NFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Detroit Lions', 'Ford Field', 'Jim Caldwell', 'NFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Green Bay Packers', 'Lambeau Field', 'Mike McCarthy', 'NFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Minnesota Vikings', 'TCF Bank Stadium', 'Mike Zimmer', 'NFC', 'North', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Atlanta Falcons', 'Georgia Dome', 'Mike Smith', 'NFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Carolina Panthers', 'Bank of America Stadium', 'Ron Rivera', 'NFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('New Orleans Saints', 'Mercedes-Benz Superdome', 'Sean Payton', 'NFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Tampa Bay Buccaneers', 'Raymond James Stadium', 'Lovie Smith', 'NFC', 'South', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Arizona Cardinals', 'University of Phoenix Stadium', 'Bruce Arians', 'NFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('St. Louis Rams', 'Edward Jones Dome', 'Jeff Fisher', 'NFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('San Francisco 49ers', 'Levis Stadium', 'Jim Harbaugh', 'NFC', 'West', 'true');
|
||||
INSERT INTO teams (name, stadium, head_coach, conference, division, active) VALUES ('Seattle Seahawks', 'CenturyLink Field', 'Pete Carroll', 'NFC', 'West', 'true');
|
||||
@ -0,0 +1,202 @@
|
||||
-- - List the names of all NFL teams'
|
||||
|
||||
SELECT name FROM teams;
|
||||
|
||||
-- name
|
||||
-- ----------------------
|
||||
-- Buffalo Bills
|
||||
-- ...
|
||||
-- Seattle Seahawks
|
||||
-- (64 rows)
|
||||
|
||||
-- - List the stadium name and head coach of all NFC teams
|
||||
|
||||
SELECT stadium, head_coach FROM teams;
|
||||
|
||||
-- stadium | head_coach
|
||||
-- -------------------------------+----------------
|
||||
-- Ralph Wilson Stadium | Doug Marrone
|
||||
-- ...
|
||||
-- CenturyLink Field | Pete Carroll
|
||||
-- (64 rows)
|
||||
|
||||
-- - List the head coaches of the AFC South
|
||||
|
||||
SELECT head_coach FROM teams WHERE conference='AFC' AND division= 'South';
|
||||
|
||||
-- head_coach
|
||||
-- ----------------
|
||||
-- Bill OBrien
|
||||
-- Chuck Pagano
|
||||
-- Gus Bradley
|
||||
-- Ken Whisenhunt
|
||||
-- Bill OBrien
|
||||
-- Chuck Pagano
|
||||
-- Gus Bradley
|
||||
-- Ken Whisenhunt
|
||||
-- (8 rows)
|
||||
|
||||
-- - The total number of players in the NFL
|
||||
|
||||
SELECT COUNT(*) FROM players;
|
||||
|
||||
-- count
|
||||
-- -------
|
||||
-- 1532
|
||||
-- (1 row)
|
||||
|
||||
-- - The team names and head coaches of the NFC North and AFC East
|
||||
|
||||
SELECT name, head_coach FROM teams WHERE conference ='NFC' AND division ='North' OR conference='AFC' AND division='East';
|
||||
|
||||
-- name | head_coach
|
||||
-- ----------------------+----------------
|
||||
-- Buffalo Bills | Doug Marrone
|
||||
-- Miami Dolphins | Joe Philbin
|
||||
-- New England Patriots | Bill Belichick
|
||||
-- New York Jets | Rex Ryan
|
||||
-- Chicago Bears | Marc Trestman
|
||||
-- Detroit Lions | Jim Caldwell
|
||||
-- Green Bay Packers | Mike McCarthy
|
||||
-- Minnesota Vikings | Mike Zimmer
|
||||
-- Buffalo Bills | Doug Marrone
|
||||
-- Miami Dolphins | Joe Philbin
|
||||
-- New England Patriots | Bill Belichick
|
||||
-- New York Jets | Rex Ryan
|
||||
-- Chicago Bears | Marc Trestman
|
||||
-- Detroit Lions | Jim Caldwell
|
||||
-- Green Bay Packers | Mike McCarthy
|
||||
-- Minnesota Vikings | Mike Zimmer
|
||||
-- (16 rows)
|
||||
|
||||
|
||||
-- - The 50 players with the highest salaries
|
||||
|
||||
SELECT name FROM players ORDER BY salary DESC LIMIT 50;
|
||||
|
||||
-- name
|
||||
-- -------------------------
|
||||
-- Peyton Manning
|
||||
-- ...
|
||||
-- Ed Reed
|
||||
-- (50 rows)
|
||||
|
||||
-- - The average salary of all NFL players
|
||||
|
||||
SELECT AVG(salary) FROM players;
|
||||
|
||||
-- avg
|
||||
-- ----------------------
|
||||
-- 1579692.539817232376
|
||||
-- (1 row)
|
||||
|
||||
-- - The names and positions of players with a salary above 10_000_000
|
||||
SELECT name, position FROM players WHERE salary > 10000000;
|
||||
-- name | position
|
||||
-- -------------------------+----------
|
||||
-- Jake Long | T
|
||||
-- Joe Thomas | T
|
||||
-- Dwight Freeney | DE
|
||||
-- Peyton Manning (buyout) | QB
|
||||
-- Peyton Manning | QB
|
||||
-- Elvis Dumervil | DE
|
||||
-- Tamba Hali | DE
|
||||
-- Philip Rivers | QB
|
||||
-- Michael Vick | QB
|
||||
-- Nnamdi Asomugha | CB
|
||||
-- Trent Williams | T
|
||||
-- Matthew Stafford | QB
|
||||
-- Cliff Avril | DE
|
||||
-- Jared Allen | DE
|
||||
-- Matt Ryan | QB
|
||||
-- Brent Grimes | CB
|
||||
-- Drew Brees | QB
|
||||
-- Vincent Jackson | WR
|
||||
-- Calais Campbell | DE
|
||||
-- Sam Bradford | QB
|
||||
-- Chris Long | DE
|
||||
-- (21 rows)
|
||||
|
||||
|
||||
-- - The player with the highest salary in the NFL
|
||||
SELECT name FROM players ORDER BY salary DESC LIMIT 1;
|
||||
|
||||
-- name
|
||||
-- ----------------
|
||||
-- Peyton Manning
|
||||
-- (1 row)
|
||||
|
||||
SELECT name, position, salary FROM players WHERE salary > 10000000 ORDER BY salary DESC; --doublecheck that I did it right
|
||||
|
||||
-- name | position | salary
|
||||
-- -------------------------+----------+----------
|
||||
-- Peyton Manning | QB | 18000000
|
||||
-- Drew Brees | QB | 15760000
|
||||
-- Dwight Freeney | DE | 14035000
|
||||
-- Elvis Dumervil | DE | 14000000
|
||||
-- Michael Vick | QB | 12500000
|
||||
-- Sam Bradford | QB | 12000000
|
||||
-- Jared Allen | DE | 11619850
|
||||
-- Matthew Stafford | QB | 11500000
|
||||
-- Matt Ryan | QB | 11500000
|
||||
-- Tamba Hali | DE | 11250000
|
||||
-- Jake Long | T | 11200000
|
||||
-- Trent Williams | T | 11000000
|
||||
-- Nnamdi Asomugha | CB | 11000000
|
||||
-- Vincent Jackson | WR | 11000000
|
||||
-- Cliff Avril | DE | 10600000
|
||||
-- Calais Campbell | DE | 10600000
|
||||
-- Joe Thomas | T | 10500000
|
||||
-- Brent Grimes | CB | 10431000
|
||||
-- Peyton Manning (buyout) | QB | 10400000
|
||||
-- Chris Long | DE | 10310000
|
||||
-- Philip Rivers | QB | 10200000
|
||||
-- (21 rows)
|
||||
|
||||
-- - The name and position of the first 100 players with the lowest salaries
|
||||
SELECT name, position FROM players ORDER BY salary ASC LIMIT 100;
|
||||
|
||||
-- name | position
|
||||
-- ------------------------+----------
|
||||
-- Phillip Dillard |
|
||||
-- Eric Kettani | RB
|
||||
-- ...
|
||||
-- Caleb Schlauderaff | G
|
||||
-- (100 rows)
|
||||
|
||||
|
||||
-- - The average salary for a DE in the nfl
|
||||
|
||||
SELECT AVG(salary) FROM players WHERE position='DE';
|
||||
-- avg
|
||||
-- ----------------------
|
||||
-- 2161326.377049180328
|
||||
-- (1 row)
|
||||
|
||||
|
||||
-- - The names of all the players on the Buffalo Bills
|
||||
SELECT players.name, teams.name FROM players, teams WHERE players.team_id=teams.id AND teams.name LIKE 'Buffalo Bills';
|
||||
|
||||
-- name | name
|
||||
-- --------------------+---------------
|
||||
-- Mario Williams | Buffalo Bills
|
||||
-- ...
|
||||
-- Michael Jasper | Buffalo Bills
|
||||
-- (59 rows)
|
||||
|
||||
|
||||
-- - The total salary of all players on the New York Giants
|
||||
SELECT SUM(players.salary) FROM players, teams WHERE players.team_id=teams.id AND teams.name LIKE 'New York Giants';
|
||||
|
||||
-- sum
|
||||
-- ----------
|
||||
-- 74179466
|
||||
-- (1 row)
|
||||
|
||||
-- - The player with the lowest salary on the Green Bay Packers
|
||||
SELECT players.name FROM players, teams WHERE players.team_id=teams.id AND teams.name LIKE '%Green Bay Packers%' ORDER BY salary ASC LIMIT 1;
|
||||
|
||||
-- name
|
||||
-- ----------------
|
||||
-- Shaky Smithson
|
||||
-- (1 row)
|
||||
@ -0,0 +1,26 @@
|
||||

|
||||
|
||||
# SQL
|
||||
|
||||
---
|
||||
Title: SQL<br>
|
||||
Type: Homework<br>
|
||||
Competencies: Basic SQL<br>
|
||||
|
||||
---
|
||||
|
||||
## Part 1: Carmen Sandiego
|
||||
|
||||
This assignment will get you comfortable with queries. Start your SQL
|
||||
explorations here.
|
||||
|
||||
Follow the [README.md](carmen-sandiego/README.md) in the carmen-sandiego folder and put your answers in `find_carmen.sql`.
|
||||
|
||||
|
||||
## Part 2: NFL
|
||||
|
||||
This assignment will give you more practice with queries, and get you to deal with some more advanced parts of the SQL language. Start this after having completed Carmen Sandiego.
|
||||
|
||||
Follow the [README.md](nfl/README.md) in the nfl folder and put your answers in the `nfl.sql` file.
|
||||
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||

|
||||
|
||||
# Realty
|
||||
|
||||
---
|
||||
Title: Realty <br>
|
||||
Source: WDI-Skywalker (2015)<br>
|
||||
Modified by: Karolin Rafalski, Thom Page <br>
|
||||
Competencies: SQL queries, aggregation
|
||||
|
||||
---
|
||||
|
||||
## Learning Objectives
|
||||
|
||||
- Practice creating a database from the command line
|
||||
- Practice seeding a database using SQL
|
||||
- Practice using the Command Line API of postgresql
|
||||
- Practice querying a database using SQL
|
||||
|
||||
## Activity
|
||||
|
||||
#### Step 1 - Create a new database
|
||||
- Create a new database called `realty_db`.
|
||||
|
||||
#### Step 2 - Create a Schema
|
||||
|
||||
- Use the given schema file named `realty_schema.sql` and create tables in your realty database which should model `Apartments`, `Offices` and `Storefronts`. They should have the following properties:
|
||||
|
||||
##### An Apartment should have:
|
||||
- id - serial primary key
|
||||
- apartment_number - integer
|
||||
- bedrooms - integer
|
||||
- bathrooms - integer
|
||||
- address - varchar
|
||||
- tenant - varchar
|
||||
- occupied - boolean
|
||||
- sq_ft - integer
|
||||
- price - integer
|
||||
|
||||
##### An Office should have:
|
||||
- id - serial primary key
|
||||
- office_number - integer
|
||||
- floors - integer
|
||||
- sq_ft - integer
|
||||
- cubicles - integer
|
||||
- bathrooms - integer
|
||||
- address - varchar
|
||||
- company - varchar
|
||||
- occupied - boolean
|
||||
- price - integer
|
||||
|
||||
##### A Storefront should have:
|
||||
|
||||
- address - varchar
|
||||
- occupied - boolean
|
||||
- price - integer
|
||||
- kitchen - boolean
|
||||
- sq_ft - integer
|
||||
- owner - varchar
|
||||
- outdoor_seating - boolean
|
||||
|
||||
- Load the seed file into your database from the command line. Use the `psql` shell to inspect your schema.
|
||||
|
||||
|
||||
#### Step 3 - Define a seed file and seed your database
|
||||
|
||||
- In a SQL file named `realty_seed.sql`, write the proper INSERT commands that will add new entries into your apartment, office and storefront tables. You should create at least 3 entries for each table. Vary the attributes of each entry so no two are alike. From the command line, load this seed file into your database.
|
||||
|
||||
|
||||
#### Step 4 - Queries
|
||||
|
||||
- In the given `realty.sql` file, write the SQL commands you would use to retrieve the following information from your database. Test each command in PSQL to make sure it is correct:
|
||||
|
||||
- The average square footage of all offices.
|
||||
- The total number of apartments.
|
||||
- The apartments where there is no tenant
|
||||
- The names of all of the companies
|
||||
- The number of cubicles and bathrooms in the 3rd office
|
||||
- The storefronts that have kitchens
|
||||
- The storefront with the highest square footage and outdoor seating
|
||||
- The office with the lowest number of cubicles
|
||||
- The office with the most cubicles and bathrooms
|
||||
@ -0,0 +1,25 @@
|
||||
-- 1. The average square footage of all offices.
|
||||
|
||||
|
||||
-- 2. The total number of apartments.
|
||||
|
||||
|
||||
-- 3. The apartments where there is no tenant
|
||||
|
||||
|
||||
-- 4. The names of all of the companies
|
||||
|
||||
|
||||
-- 5. The number of cubicles and bathrooms in the 3rd office
|
||||
|
||||
|
||||
-- 6. The storefronts that have kitchens
|
||||
|
||||
|
||||
-- 7. The storefront with the highest square footage and outdoor seating
|
||||
|
||||
|
||||
-- 8. The office with the lowest number of cubicles
|
||||
|
||||
|
||||
-- 9. The office with the most cubicles and bathrooms
|
||||
@ -0,0 +1 @@
|
||||
-- enter your schema for apartments, offices and storefronts below
|
||||
@ -0,0 +1 @@
|
||||
--enter your seed data below
|
||||
@ -0,0 +1,83 @@
|
||||

|
||||
|
||||
# Realty
|
||||
|
||||
---
|
||||
Title: Realty <br>
|
||||
Source: WDI-Skywalker (2015)<br>
|
||||
Modified by: Karolin Rafalski, Thom Page <br>
|
||||
Competencies: SQL queries, aggregation
|
||||
|
||||
---
|
||||
|
||||
## Learning Objectives
|
||||
|
||||
- Practice creating a database from the command line
|
||||
- Practice seeding a database using SQL
|
||||
- Practice using the Command Line API of postgresql
|
||||
- Practice querying a database using SQL
|
||||
|
||||
## Activity
|
||||
|
||||
#### Step 1 - Create a new database
|
||||
- Create a new database called `realty_db`.
|
||||
- _NOTE!_ To create a new postgres database without connecting to psql, in terminal bash just run `psql [databasename]` where [databasename] is whatever you want to name your new database.
|
||||
|
||||
#### Step 2 - Create a Schema
|
||||
|
||||
- Use the given schema file named `realty_schema.sql` and create tables in your realty database which should model `Apartments`, `Offices` and `Storefronts`. They should have the following properties:
|
||||
|
||||
##### An Apartment should have:
|
||||
- id - serial primary key
|
||||
- apartment_number - integer
|
||||
- bedrooms - integer
|
||||
- bathrooms - integer
|
||||
- address - varchar
|
||||
- tenant - varchar
|
||||
- occupied - boolean
|
||||
- sq_ft - integer
|
||||
- price - integer
|
||||
|
||||
##### An Office should have:
|
||||
- id - serial primary key
|
||||
- office_number - integer
|
||||
- floors - integer
|
||||
- sq_ft - integer
|
||||
- cubicles - integer
|
||||
- bathrooms - integer
|
||||
- address - varchar
|
||||
- company - varchar
|
||||
- occupied - boolean
|
||||
- price - integer
|
||||
|
||||
##### A Storefront should have:
|
||||
|
||||
- address - varchar
|
||||
- occupied - boolean
|
||||
- price - integer
|
||||
- kitchen - boolean
|
||||
- sq_ft - integer
|
||||
- owner - varchar
|
||||
- outdoor_seating - boolean
|
||||
|
||||
- Load the seed file into your database from the command line. Use the `psql` shell to inspect your schema.
|
||||
|
||||
|
||||
#### Step 3 - Define a seed file and seed your database
|
||||
|
||||
- In a SQL file named `realty_seed.sql`, write the proper INSERT commands that will add new entries into your apartment, office and storefront tables. You should create at least 3 entries for each table. Vary the attributes of each entry so no two are alike. From the command line, load this seed file into your database.
|
||||
|
||||
|
||||
#### Step 4 - Queries
|
||||
|
||||
- In the given `realty.sql` file, write the SQL commands you would use to retrieve the following information from your database. Test each command in PSQL to make sure it is correct:
|
||||
|
||||
- The average square footage of all offices.
|
||||
- The total number of apartments.
|
||||
- The apartments where there is no tenant
|
||||
- The names of all of the companies
|
||||
- The number of cubicles and bathrooms in the 3rd office
|
||||
- The storefronts that have kitchens
|
||||
- The storefront with the highest square footage and outdoor seating
|
||||
- The office with the lowest number of cubicles
|
||||
- The office with the most cubicles and bathrooms
|
||||
@ -0,0 +1,83 @@
|
||||

|
||||
|
||||
# Realty
|
||||
|
||||
---
|
||||
Title: Realty <br>
|
||||
Source: WDI-Skywalker (2015)<br>
|
||||
Modified by: Karolin Rafalski, Thom Page <br>
|
||||
Competencies: SQL queries, aggregation
|
||||
|
||||
---
|
||||
|
||||
## Learning Objectives
|
||||
|
||||
- Practice creating a database from the command line
|
||||
- Practice seeding a database using SQL
|
||||
- Practice using the Command Line API of postgresql
|
||||
- Practice querying a database using SQL
|
||||
|
||||
## Activity
|
||||
|
||||
#### Step 1 - Create a new database
|
||||
- Create a new database called `realty_db`.
|
||||
- _NOTE!_ To create a new postgres database without connecting to psql, in terminal bash just run `psql [databasename]` where [databasename] is whatever you want to name your new database.
|
||||
|
||||
#### Step 2 - Create a Schema
|
||||
|
||||
- Use the given schema file named `realty_schema.sql` and create tables in your realty database which should model `Apartments`, `Offices` and `Storefronts`. They should have the following properties:
|
||||
|
||||
##### An Apartment should have:
|
||||
- id - serial primary key
|
||||
- apartment_number - integer
|
||||
- bedrooms - integer
|
||||
- bathrooms - integer
|
||||
- address - varchar
|
||||
- tenant - varchar
|
||||
- occupied - boolean
|
||||
- sq_ft - integer
|
||||
- price - integer
|
||||
|
||||
##### An Office should have:
|
||||
- id - serial primary key
|
||||
- office_number - integer
|
||||
- floors - integer
|
||||
- sq_ft - integer
|
||||
- cubicles - integer
|
||||
- bathrooms - integer
|
||||
- address - varchar
|
||||
- company - varchar
|
||||
- occupied - boolean
|
||||
- price - integer
|
||||
|
||||
##### A Storefront should have:
|
||||
|
||||
- address - varchar
|
||||
- occupied - boolean
|
||||
- price - integer
|
||||
- kitchen - boolean
|
||||
- sq_ft - integer
|
||||
- owner - varchar
|
||||
- outdoor_seating - boolean
|
||||
|
||||
- Load the seed file into your database from the command line. Use the `psql` shell to inspect your schema.
|
||||
|
||||
|
||||
#### Step 3 - Define a seed file and seed your database
|
||||
|
||||
- In a SQL file named `realty_seed.sql`, write the proper INSERT commands that will add new entries into your apartment, office and storefront tables. You should create at least 3 entries for each table. Vary the attributes of each entry so no two are alike. From the command line, load this seed file into your database.
|
||||
|
||||
|
||||
#### Step 4 - Queries
|
||||
|
||||
- In the given `realty.sql` file, write the SQL commands you would use to retrieve the following information from your database. Test each command in PSQL to make sure it is correct:
|
||||
|
||||
- The average square footage of all offices.
|
||||
- The total number of apartments.
|
||||
- The apartments where there is no tenant
|
||||
- The names of all of the companies
|
||||
- The number of cubicles and bathrooms in the 3rd office
|
||||
- The storefronts that have kitchens
|
||||
- The storefront with the highest square footage and outdoor seating
|
||||
- The office with the lowest number of cubicles
|
||||
- The office with the most cubicles and bathrooms
|
||||
@ -0,0 +1,54 @@
|
||||
-- 1. The average square footage of all offices.
|
||||
|
||||
SELECT AVG(sq_ft) FROM office;
|
||||
|
||||
|
||||
|
||||
-- 2. The total number of apartments.
|
||||
|
||||
SELECT MAX(id) FROM apartment;
|
||||
|
||||
|
||||
|
||||
-- 3. The apartments where there is no tenant
|
||||
|
||||
SELECT FROM apartment WHERE tenant IS NULL;
|
||||
|
||||
|
||||
|
||||
-- 4. The names of all of the companies
|
||||
|
||||
SELECT company FROM office;
|
||||
|
||||
|
||||
|
||||
-- 5. The number of cubicles and bathrooms in the 3rd office
|
||||
|
||||
SELECT cubicles, bathrooms FROM office WHERE id=3;
|
||||
|
||||
|
||||
|
||||
-- 6. The storefronts that have kitchens
|
||||
|
||||
SELECT kitchen FROM storefront WHERE kitchen='t';
|
||||
|
||||
|
||||
--##############this one was a little tricky to figure out because it wasn't in the lesson MD.
|
||||
|
||||
|
||||
-- 7. The storefront with the highest square footage and outdoor seating
|
||||
|
||||
SELECT MAX(sq_ft) FROM storefront WHERE outdoor_seating='t';
|
||||
|
||||
|
||||
|
||||
-- 8. The office with the lowest number of cubicles
|
||||
|
||||
SELECT MIN(cubicles) FROM office;
|
||||
|
||||
|
||||
|
||||
-- 9. The office with the most cubicles and bathrooms
|
||||
|
||||
SELECT MAX(cubicles), MAX(bathrooms) FROM office;
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
-- enter your schema for apartments, offices and storefronts below
|
||||
|
||||
-- already ran this code in CLI so it is commented out.
|
||||
|
||||
DROP DATABASE realty_db;
|
||||
|
||||
CREATE DATABASE realty_db;
|
||||
|
||||
DROP TABLE apartment;
|
||||
DROP TABLE office;
|
||||
DROP TABLE storefront;
|
||||
|
||||
|
||||
CREATE TABLE apartment(id serial, apartment_number int, bedrooms int, bathrooms int, address varchar(180), tenant varchar(50),occupied boolean, sq_ft int, price int);
|
||||
|
||||
CREATE TABLE office(id serial, office_number int, floor int, sq_ft int, cubicles int, bathrooms int, address varchar(180), company varchar(30), occupied boolean, price int);
|
||||
|
||||
CREATE TABLE storefront(address varchar(180), occupied boolean, price int, kitchen boolean, sq_ft int, owner varchar(50), outdoor_seating boolean);
|
||||
|
||||
|
||||
|
||||
--Commands I added at the end to see tables created
|
||||
|
||||
SELECT * FROM apartment;
|
||||
SELECT * FROM office;
|
||||
SELECT * FROM storefront;
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
--enter your seed data below
|
||||
|
||||
|
||||
INSERT INTO apartment(apartment_number, bedrooms, bathrooms, address, tenant, occupied, sq_ft, price) VALUES (3, 2, 3, '222 Ladybug Lane', 'Papa John',true, 1500,3000);
|
||||
|
||||
INSERT INTO apartment(apartment_number, bedrooms, bathrooms, address, tenant, occupied, sq_ft, price) VALUES (5, 6, 4, '999 My Street', 'rockin johnny',true, 1700,2000);
|
||||
|
||||
INSERT INTO apartment(apartment_number, bedrooms, bathrooms, address, tenant, occupied, sq_ft, price) VALUES (1, 8, 7, '64 Palace Drive', 'betty davis',true, 1250,1000);
|
||||
|
||||
|
||||
INSERT INTO office(office_number, floor, sq_ft, cubicles, bathrooms, address, company, occupied, price) VALUES(3,6, 800,5,1,'405 Jersey Ave','My Biz',true, 2000);
|
||||
|
||||
INSERT INTO office(office_number, floor, sq_ft, cubicles, bathrooms, address, company, occupied, price) VALUES(6,12, 950, 5,2,'505 Pizza Boulevard','Too Much Trouble',true, 4000);
|
||||
|
||||
INSERT INTO office(office_number, floor, sq_ft, cubicles, bathrooms, address, company, occupied, price) VALUES(1,4, 1800,9,2,'905 Elbow Lane','Rocket Store',false, 7000);
|
||||
|
||||
INSERT INTO storefront(address, price, kitchen, sq_ft, owner, outdoor_seating)VALUES('234 Main St', 1200, true, 1500, 'Eddie', true);
|
||||
|
||||
INSERT INTO storefront(address, price, kitchen, sq_ft, owner, outdoor_seating)VALUES('35 Awesome Street', 1600, true, 1400, 'Joey', true);
|
||||
|
||||
INSERT INTO storefront(address, price, kitchen, sq_ft, owner, outdoor_seating)VALUES('234 Wonder Wall Place', 1000, false, 1200, 'Billie', false);
|
||||
|
||||
|
||||
-- adding this on end to see the data added
|
||||
|
||||
|
||||
SELECT * FROM apartment;
|
||||
SELECT * FROM office;
|
||||
SELECT * FROM storefront;
|
||||
Loading…
Reference in new issue