Skip to content

Commit

Permalink
Add postgres day 1 homework
Browse files Browse the repository at this point in the history
  • Loading branch information
peferron committed Nov 2, 2016
1 parent 64df103 commit f243b4d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions postgres_homework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# PostgreSQL homework

## Day 1

1. Select all the tables we created (and only those) from `pg_class`.

```
SELECT relname FROM pg_class
WHERE relname !~ '^(pg_|sql_)'
AND relkind = 'r';
```

2. Write a query that finds the country name of the LARP Club event.

```
SELECT c.country_name FROM countries c
JOIN venues v ON c.country_code = v.country_code
JOIN events e ON v.venue_id = e.venue_id
WHERE e.title = 'LARP Club';
```

3. Alter the `venues` table to contain a boolean column called `active`, with the default value of `true`.

```
ALTER TABLE venues
ADD COLUMN active BOOLEAN DEFAULT TRUE;
```

0 comments on commit f243b4d

Please sign in to comment.