{"id":13727471,"url":"https://github.com/mike-works/sql-fundamentals","last_synced_at":"2026-01-30T01:21:28.257Z","repository":{"id":27151151,"uuid":"111384465","full_name":"mike-works/sql-fundamentals","owner":"mike-works","description":"Mike North's SQL Fundamentals and Professional SQL Courses","archived":false,"fork":false,"pushed_at":"2025-05-05T22:29:56.000Z","size":30996,"stargazers_count":170,"open_issues_count":52,"forks_count":107,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-05T23:31:11.280Z","etag":null,"topics":["course","database","mysql","nodejs","postgresql","rest-api","sqlite"],"latest_commit_sha":null,"homepage":"https://frontendmasters.com/courses/sql-fundamentals/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mike-works.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-20T08:47:16.000Z","updated_at":"2025-02-25T09:05:13.000Z","dependencies_parsed_at":"2025-01-08T23:56:54.849Z","dependency_job_id":"2a5cb66b-95b3-472a-bc1d-6e1b7a9db71b","html_url":"https://github.com/mike-works/sql-fundamentals","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike-works%2Fsql-fundamentals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike-works%2Fsql-fundamentals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike-works%2Fsql-fundamentals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike-works%2Fsql-fundamentals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mike-works","download_url":"https://codeload.github.com/mike-works/sql-fundamentals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252965484,"owners_count":21832897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["course","database","mysql","nodejs","postgresql","rest-api","sqlite"],"created_at":"2024-08-03T01:03:58.544Z","updated_at":"2026-01-30T01:21:23.238Z","avatar_url":"https://github.com/mike-works.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align='center'\u003e\n  \u003ca href=\"https://mike.works\" target='_blank'\u003e\n    \u003cimg height=40 src='https://assets.mike.works/img/login_logo-33a9e523d451fb0d902f73d5452d4a0b.png' /\u003e\n  \u003c/a\u003e \n\u003c/p\u003e\n\u003cp align='center'\u003e\n  \u003ca href=\"https://mike.works/course/sql-fundamentals-ad811af\" target='_blank'\u003e\n    \u003cimg height=150 src='https://user-images.githubusercontent.com/558005/33009968-b8a0ea60-cd7c-11e7-81af-b48a6273b12b.png' /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align='center'\u003e\n  \u003ca href=\"https://mike.works/course/professional-sql-c9c7184\" target='_blank'\u003e\n    \u003cimg height=150 src='https://user-images.githubusercontent.com/558005/38008070-40db7658-3212-11e8-879e-7efcf767777e.png' /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align='center'\u003e\n \n  \u003ca href=\"https://travis-ci.org/mike-works/sql-fundamentals?branch=solutions-pro\" title=\"Build Status\"\u003e\n    \u003cimg title=\"Build Status\" src=\"https://travis-ci.org/mike-works/sql-fundamentals.svg?branch=solutions-pro\"/\u003e\n  \u003c/a\u003e\n   \u003ca href=\"https://github.com/mike-works/sql-fundamentals/releases\" title=\"Version\"\u003e\n    \u003cimg title=\"Version\" src=\"https://img.shields.io/github/tag/mike-works/sql-fundamentals.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align='center'\u003e\nThis is the example project used for the \u003ca title=\"Mike.Works\" href=\"https://mike.works\"\u003eMike.Works\u003c/a\u003e \u003ca title=\"SQL Fundamentals\" href=\"https://mike.works/course/sql-fundamentals-ad811af\"\u003eSQL Fundamentals\u003c/a\u003e and \u003ca title=\"Professional SQL\" href=\"https://mike.works/course/professional-sql-c9c7184\"\u003eProfessional SQL\u003c/a\u003e courses.\n\u003c/p\u003e\n\n# Course outline and slides\n\n- [View course outline here](https://mike.works/course/sql-fundamentals-ad811af)\n- [View slides here](https://docs.mike.works/sql-slides)\n\n# What are we building?\n\nWe'll be working with several flavors of the [Northwind Database](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/linq/downloading-sample-databases), which Microsoft uses to demonstrate a wide range of features across their MS Access and MS SQL Server product lines. You'll be writing some application code in a small [Node.js](https://nodejs.org) web application (built with [Express](https://expressjs.com)) to view and make changes to this data.\n\nHere's what it looks like (and [here](https://damp-oasis-38940.herokuapp.com/) is a live demo):\n\n\u003cp align=\"center\"\u003e\n\u003cimg height=400 src=\"https://user-images.githubusercontent.com/558005/35312473-7646b68c-0070-11e8-83df-25800047b763.png\" /\u003e\n\u003c/p\u003e\n\nThis app is not in a good state at the beginning of the workshop. Features are missing, there are major performances, and quite a few database-related bugs. We'll fix all these problems and learn as we go!\n\n# Setup Instructions\n\n## Clone this project\n\nIn your terminal, run\n\n```sh\ngit clone https://github.com/mike-works/sql-fundamentals sql\ncd sql\n```\n\n## Database Software Setup\n\nThis project is used for two workshops. [SQL Fundamentals](https://mike.works/course/sql-fundamentals-ad811af) may be completed using either [SQLite](https://www.sqlite.org/index.html), [MySQL](https://www.mysql.com/) or [PostgreSQL](https://www.postgresql.org/), and [Professional SQL](https://mike.works/course/professional-sql-c9c7184) requires either MySQL or PostgreSQL.\n\nTo set up the database software, please check out these guides\n\n- [Installing SQLite 3](./SQLITE_SETUP.md)\n- [Installing Postgres 10](./POSTGRES_SETUP.md)\n- [Installing MySQL 5.7](./MYSQL_SETUP.md)\n\n## Install node dependencies\n\nIf you only intend to complete the [SQL Fundamentals](https://mike.works/course/sql-fundamentals-ad811af) workshop (exercises 1-10), and wish to ONLY use SQLite, you can run\n\n```sh\nnpm install --no-optional\n```\n\nIf you wish to use MySQL or PostgreSQL, or proceed beyond exercise 10 for the [Professional SQL](https://mike.works/course/professional-sql-c9c7184) course, please include optional dependencies\n\n```sh\nnpm install\n```\n\n## Database Initialization\n\n#### SQLite\n\nThe `./master.sqlite` file already contains the data we'll be working with, but we'll want to create a copy called `./dev.sqlite` in case we mess up and have to reset to a known good state. To create this working copy, please run\n\n```sh\nnpm run db:setup:sqlite\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhat does this do?\u003c/summary\u003e\n  Ultimately, the command runs \u003ca href=\"./scripts/db/setup/sqlite.sh\"\u003ethis script\u003c/a\u003e\n\u003c/details\u003e\n\nValidate that your SQLite database works by running\n\n```sh\nsqlite3 dev.sqlite \"SELECT count(id) FROM Employee\"\n#\u003e 9\n```\n\n#### PostgreSQL\n\nThe `./sql/northwind.pg.sql` script contains the necessary commands for setting up the PostgreSQL schema, and the `./sql/northwind_data.sql` file will fill the database with data. The database setup that includes database creation, running these scripts, and setting appropriate permissions can be run by executing this command\n\n```sh\nnpm run db:setup:pg\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhat does this do?\u003c/summary\u003e\n  Ultimately, the command runs \u003ca href=\"./scripts/db/setup/pg.sh\"\u003ethis script\u003c/a\u003e\n\u003c/details\u003e\n\nValidate that your PostgreSQL database works by running\n\n```sh\npsql northwind -c \"SELECT count(id) FROM Employee\"\n#\u003e  count\n#\u003e -------\n#\u003e      9\n#\u003e (1 row)\n```\n\n#### MySQL\n\nThe `./sql/northwind.mysql.sql` script contains the necessary commands for setting up the MySQL schema, and the `./sql/northwind_data.sql` file will fill the database with data. The database setup that includes database creation, running these scripts, and setting appropriate permissions can be run by executing this command\n\n```sh\nnpm run db:setup:mysql\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhat does this do?\u003c/summary\u003e\n  Ultimately, the command runs \u003ca href=\"./scripts/db/setup/mysql.sh\"\u003ethis script\u003c/a\u003e\n\u003c/details\u003e\n\nValidate that your MySQL database works by running\n\n```sh\nmysql -D northwind -e \"SELECT count(id) FROM Employee\"\n#\u003e +-----------+\n#\u003e | count(id) |\n#\u003e +-----------+\n#\u003e |         9 |\n#\u003e +-----------+\n```\n\n## Run the tests\n\nThere's an initial set of tests that ensure the app is correctly setup for the beginning of the course. You should be able to run this command and see them all passing\n\n```sh\n# Test against SQLite\nnpm run test --- EX00\n# Test against PostgreSQL\nDB_TYPE=pg npm run test --- EX00\n```\n\n# Commands \u0026 Scripts\n\n## Starting the app\n\nThe app can be built and started up by running\n\n```sh\nnpm run watch\n```\n\nThis will shutdown, rebuild and restart the app whenever source files are changed. If you want to start the app so that a debugger may be connected, run\n\n```sh\nnpm run watch:debug\n```\n\n## Running Tests\n\nYou may run a subset of test suites whotes names match a string by running\n\n```sh\nnpm run test --- \u003cstring\u003e\n```\n\nor if you wish for the tests to re-run on code changes\n\n```sh\nnpm run test:watch --- \u003cstring\u003e\n```\n\nand if you want to connect a debugger...\n\n```sh\nnpm run test --- EX00 --inspect-brk\n```\n\nAdditionally, you can run tests for a particular exercise, and all exercises before it. This is useful when trying to ensure that an exercise can be completed without breaking previous work.\n\n```sh\nnpm run test:ex 4 # run tests up through exercise 4\n```\n\nor, if you want to re-run tests on code changes\n\n```sh\nnpm run test:ex:watch 4\n```\n\n## Choosing a database\n\nThis project is designed to work with three databases: SQLite (default), PostgreSQL and MySQL. The database that's used is determined by the `DB_TYPE` environment variable\n\n| DB_TYPE value | Database   |\n| ------------- | ---------- |\n| `pg`          | PostgreSQL |\n| `mysql`       | MySQL      |\n| anything else | SQLite     |\n\nThis environment variable can be used when running or testing the app. For example\n\n```sh\nDB_TYPE=mysql npm run watch # Run the app using MySQL, and rebuild whenever source code changes\n\nDB_TYPE=pg npm run test:ex 9 # Run tests up to and including exercise 9 using PostgreSQL\n```\n\n# Recommended Tools\n\nThe following tools are recommended for this course. Depending on which database(s) you choose to use for the course, please download the appropriate tools by following their respective installation instructions.\n\n- _All Databases_\n\n  - [Visual Studio Code](https://code.visualstudio.com) - A fantastic code editor that we'll be using for its static analysis features and a few SQL-specific extensions\n  - VS Code Extensions\n    - [Better Comments](https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments) - to hilight urgent comments more prominently\n    - [SQL Tools](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools) - to connect to databases and run queries right from within our code editor\n    - [vscode-sql-template-literal](https://marketplace.visualstudio.com/items?itemName=forbeslindesay.vscode-sql-template-literal) - for syntax hilighting of tagged template literals in our JavaScript code.\n    - [TSLint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) - type-checking and other static analysis on our code\n\n- _MySQL_\n  - [Sequel Pro](https://www.sequelpro.com/) (OS X only)\n  - [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) (OS X, Windows, Linux)\n  - [VSCode MySQL Syntax](https://marketplace.visualstudio.com/items?itemName=jakebathman.mysql-syntax) - syntax hilighting for MySQL-specific syntax\n- _PostgreSQL_\n  - [pgAdmin](https://www.pgadmin.org/download/) (OS X, Windows, Linux)\n  - [vscode-postgresql](https://marketplace.visualstudio.com/items?itemName=JPTarquino.postgresql) - for autocomplete and syntax hilighting of Postgres-specific SQL\n- _SQLite_\n  - [DB Browser for SQLite](http://sqlitebrowser.org/) (OS X, Windows, Linux)\n\n# How To Deploy on Heroku\n\nIf for some reason, you cannot set up your own local database software, you can deploy this app onto heroku and use their $7/month hosted [PostgreSQL](https://www.postgresql.org) service.\n\n### Step 1\n\nClick this button to deploy the app to heroku. Because the database is large (about 700K rows) it cannot be run with their free database option.\n[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)\n\n### Step 2\n\nPopulate the database with data. This can be done one of two ways\n\n#### If you have a local database already setup and running\n\nUse the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) posgtres push utility (recommended)\n\n```sh\nheroku pg:push northwind DATABASE_URL --app replace-this-with-your-heroku-app-name\n```\n\n#### If you don't have a local database to push\n\nUse the `psql` command line utility to run the huge PostgreSQL setup script. This will take at least several minutes.\n\n```sh\nheroku run \"psql \\$DATABASE_URL?ssl=true \u003c northwind.sql -q\" --app sql456\n```\n\n# Build Status\n\n| Solutions Branch                                                                               | Status                                                                                                                                                                                  |\n| ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [SQL Fundamentals](https://github.com/mike-works/sql-fundamentals/tree/solutions-fundamentals) | [![Build Status](https://travis-ci.org/mike-works/sql-fundamentals.svg?branch=solutions-fundamentals)](https://travis-ci.org/mike-works/sql-fundamentals?branch=solutions-fundamentals) |\n| [SQL Pro](https://github.com/mike-works/sql-fundamentals/tree/solutions-pro)                   | [![Build Status](https://travis-ci.org/mike-works/sql-fundamentals.svg?branch=solutions-pro)](https://travis-ci.org/mike-works/sql-fundamentals?branch=solutions-pro)                   |\n\n# License\n\nWhile the general license for this project is the BSD 3-clause, the exercises\nthemselves are proprietary and are licensed on a per-individual basis, usually\nas a result of purchasing a ticket to a public workshop, or being a participant\nin a private training.\n\nHere are some guidelines for things that are **OK** and **NOT OK**, based on our\nunderstanding of how these licenses work:\n\n### OK\n\n- Using everything in this project other than the exercises (or accompanying tests)\n  to build a project used for your own free or commercial training material\n- Copying code from build scripts, configuration files, tests and development\n  harnesses that are not part of the exercises specifically, for your own projects\n- As an owner of an individual license, using code from tests, exercises, or\n  exercise solutions for your own non-training-related project.\n\n### NOT OK (without express written consent)\n\n- Using this project, or any subset of\n  exercises contained within this project to run your own workshops\n- Writing a book that uses the code for these exercises\n- Recording a screencast that contains one or more of this project's exercises\n\n# Copyright\n\n\u0026copy; 2018 [Mike.Works](https://mike.works), All Rights Reserved\n\n###### This material may not be used for workshops, training, or any other form of instructing or teaching developers, without express written consent\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike-works%2Fsql-fundamentals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmike-works%2Fsql-fundamentals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike-works%2Fsql-fundamentals/lists"}