Git Product home page Git Product logo

sql_quiz's Introduction

Overview

This repo contains the material for the SQL quizzes in CMC's CSCI143: Big Data class.

Notes with example problems and explanations can be found in the quiz_notes_?.sql files. For each SQL command in the notes, you need to understand the output in both SQLite and Postgres. In most cases, the output will be the same. Differences are usually because sqlite3 is less standards compliant than postgres.

Terminology Note: SQLite and Postgres are two different database engines or RDBMSes. SQL is the language used to interact with the database.

In the actual quiz, you will have 2^2 problems to complete and the quiz will be worth 2^3 points. Each problem will be worth 2^1 points: 2^0 points for the correct sqlite3 output, and 2^0 points for the correct postgres output. If the command does not result in an error, you should provide the full table of the output. If the command does result in an error, just write "error". You do not need to provide the full error message. If the output of both sqlite3 and postgres is the same, you can just write "sqlite3 and postgres are the same" instead of redrawing the output.

Notice that I've switched to SQL math notation here instead of python. One of the difficulties of using SQL is that the notation is different from most other programming languages.

Running from SQLite

To create a SQLite database, run the command

$ sqlite3 quiz.db < create_tables.sql

You can run all practice problems at once with the command

$ cat quiz_example_?.sql | sqlite3 quiz.db

You might find the following incantation provides more useful output

$ (echo '.echo on' && echo '.mode markdown' && cat quiz_example_?.sql) | sqlite3 quiz.db

You can enter an interactive session with

$ sqlite3 quiz.db

Running from Postgres

To create a postgres database, run the commands

$ docker-compose up --build -d

The Dockerfile runs the create_tables.sql files inside of postgres to populate the database with example values.

You can run all practice problems at once with the incantation

$ docker-compose < quiz_notes_?.sql exec -T pg psql -a

You can enter an interactive SQL session with the command

$ docker-compose exec pg psql

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.