Skip to content

Commit

Permalink
Split into sub-projects and clean up READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
dgroomes committed Feb 4, 2021
1 parent 378b8f1 commit 258ec41
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 39 deletions.
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
# sql-playground

📚 Learning and exploring SQL (and Postgres in particular).
📚 Learning and exploring SQL (Postgres in particular).

---

## Instructions

Requires: Docker

1. Start a Postgres instance using Docker Compose
* Execute `docker-compose up --detach`
1. Explore the database!
* Enter a session on the command line with `psql --username postgres --host localhost`
1. Define some test tables and test data
* Apply the DDL and DML files
* `psql --username postgres --host localhost -f observations/observations-schema.ddl`
* `psql --username postgres --host localhost -f observations/observations-data.sql`
1. Stop the Postgres Docker container
* Execute `docker-compose down`
## Standalone sub-projects

This repository illustrates different concepts, patterns and examples via standalone sub-projects. Each sub-project is
completely independent of the others and do not depend on the root project. This _standalone sub-project constraint_
forces the sub-projects to be complete and maximizes the reader's chances of successfully running, understanding, and
re-using the code.

The sub-projects include:

### `arrays/`

Showcasing the `array` SQL data type.

See the README in [arrays/](arrays/).

### `lag/`

Showcasing the `lag` Postgres function which is a part of Postgres' windowing support.

See the README in [lag/](lag/).

### `docker/`

Run Postgres in a Docker container using Docker Compose.

See the README in [docker/](docker/).

### `administration/`

Exploring how to administrate Postgres via its many tools like `pg_ctl`.

See the README in [administration/](administration/).

## WishList

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# postgres-administration
# administration

Exploring how to administrate Postgres via its many tools like `pg_ctl`.

Expand Down
13 changes: 13 additions & 0 deletions arrays/arrays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# arrays

Showcasing the `array` SQL data type.

A dataset of "observations" is used to explore the `array` data type.

## Instructions

* Apply the schema:
* `psql --username postgres --host localhost -f observations-schema.ddl`
* Insert test data:
* `psql --username postgres --host localhost -f observations-data.sql`
* Try out the queries in `observations-explore.sql` and learn about SQL arrays!
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# docker

Run Postgres in a Docker container using Docker Compose.

## Instructions

1. Start a Postgres instance using Docker Compose:
* `docker-compose up --detach`
1. Explore the database! Enter a session on the command line:
* `psql --username postgres --host localhost`
1. Stop the Postgres Docker container:
* `docker-compose down`

## Referenced Material

* [Docker Compose](https://docs.docker.com/compose/)
File renamed without changes.
18 changes: 18 additions & 0 deletions lag/lag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# lag

Showcasing the `lag` Postgres function which is a part of Postgres' windowing support.

Specifically, I wanted to illustrate a query where each row needs to be compared to the row preceding it.

## Instructions

* Apply the schema:
* `psql --username postgres --host localhost -f snapshots-schema.ddl`
* Insert test data:
* `psql --username postgres --host localhost -f snapshots-data.sql`
* Try out the queries `snapshots-explore.sql` and learn about `lag`!

## Referenced Material

* [Postgres official docs: "Window Functions" tutorial](https://www.postgresql.org/docs/13/tutorial-window.html)
* [Postgres official docs: "Window Functions" reference](https://www.postgresql.org/docs/13/functions-window.html)
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions observations/observations.md

This file was deleted.

16 changes: 0 additions & 16 deletions snapshots/snapshots.md

This file was deleted.

0 comments on commit 258ec41

Please sign in to comment.