about summary refs log tree commit diff
path: root/README.md
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-07-27T10·16+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-07-27T10·16+0100
commitdf13b761ff945db894ade4dba6c68fb6f14c8615 (patch)
tree26737576453b2b390203fd2c23fccb113ce705d2 /README.md
parent722205b0818a7fb2280941554baaff9400808d65 (diff)
Define table schema and CSVs to populate the database
TL;DR:
- Created src/init.sql, which defines the tables
- Created a data/ directory to house .csv data to populate our db
- Updated the README with usage instructions
Diffstat (limited to 'README.md')
-rw-r--r--README.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/README.md b/README.md
index e69de29bb2d1..e6d20d649e02 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,44 @@
+# TopTal take-home #2
+
+All of the commands defined herein should be run from the top-level directory of
+this repository (i.e. the directory in which this file exists).
+
+## Database
+
+Create a new database named `db.sqlite3` with:
+
+```shell
+$ sqlite3 db.sqlite3
+```
+
+Initialize the schema with:
+
+```
+sqlite> .read src/init.sql
+```
+
+You can verify that you successfully initialized the database by running:
+
+```
+sqlite> .tables
+sqlite> .schema Accounts
+sqlite> .schema Trips
+```
+
+Populate the database with some dummy values using the following:
+
+```
+sqlite> PRAGMA foreign_keys = on;
+sqlite> .mode csv
+sqlite> .import data/accounts.csv Accounts
+sqlite> .import data/trips.csv Trips
+```
+
+You can verify you successfully populated the tables with:
+
+```
+sqlite> .mode columns
+sqlite> .headers on
+sqlite> SELECT * FROM Accounts;
+sqlite> SELECT * FROM Trips;
+```