Skip to content

SQL course Github order #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The material in this repository is divided by topic.

* Ruby
* SQL
* [SQL](sql/Open_SQL_Overview.md)
* Rails
* HTML/CSS
* JavaScript
Expand Down
173 changes: 173 additions & 0 deletions sql/Open_SQL_Overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# SQL

## Topics Covered

- [Getting Started](#getting-started)
- [SQL Fundamentals](#sql-fundamentals)
- [Object Relational Model](#object-relational-model)
- [Active Record](#active-record)
- [Active Record II](#active-record-ii)
- [Active Record under-the-hood](#active-record-under-the-hood)

## Notes

SQL is the second module in the App Academy Full Stack Developer Curriculum.

As with all future modules, any "Bonus" projects are to be completed after the
standard projects for each day are completed. Sometimes that could mean going
back to previous day's "Bonus" projects if you otherwise finish early.
Additional Resources are readings, videos, or articles that are not required,
but will serve to deepen your understanding of a topic. They will be denoted
with a specific icon in your task menu.


## Getting Started"
## SQL Fundamentals
- [ ] 1. [Setting up a Development Environment (Phase 2)](../course/readings/dev-setup.md#phase-2-backend-development)
- [ ] 2. [Nontechnical Overview of SQL](readings/sql_nontech.md)
- [ ] 3. [Programming Paradigms](readings/paradigms.md)
- [ ] 4. [SQL For The Impatient](readings/sql-intro.md)
- [ ] 5. [A Visual Explanation of Joins](https://blog.codinghorror.com/a-visual-explanation-of-sql-joins/)
- [ ] 6. [Self Joins](readings/self-joins.md)
- [ ] 7. [Formatting SQL Code](readings/formatting.md)
- [ ] 8. [Subqueries](https://sqlbolt.com/topic/subqueries)
- [ ] 9. [NULL](readings/null.md)
- [ ] 10. [CASE](http://www.postgresqltutorial.com/postgresql-case/)
- [ ] 11. [COALESCE](http://www.postgresqltutorial.com/postgresql-coalesce/)
- [ ] 12. [PostgreSQL Setup](readings/setup.md)
- [ ] 13. [SQL Fundamentals Quiz](quizzes/sql_i.md)
- [ ] 14. [SQL Bolt Tutorial; sections 1 - 12](https://sqlbolt.com/)
- [ ] 15. [Indexing Queries(Read Sections 1.3 - 1.5)](https://www.sqlite.org/queryplanner.html)
- [ ] 16. [Breaking Down a SQL Query Plan](https://player.vimeo.com/video/321636797)
- [ ] 17. [Postgres EXPLAIN documentation](https://www.postgresql.org/docs/current/using-explain.html)
- [ ] 18. [Understanding Execution Plans in PostgreSQ](https://www.vertabelo.com/blog/technical-articles/understanding-execution-plans-in-postgresql)
- [ ] 19. [Creating an Index using SQL](https://www.w3schools.com/sql/sql_create_index.asp)
- [ ] 20. [Creating a SQL Database in PostgreSQL](readings/creating_postgres_database.md)
- [ ] 21. [Using JSONB in PostgreSQL](https://www.compose.com/articles/faster-operations-with-the-jsonb-data-type-in-postgresql)
- [ ] 22. [HashSet Solution Walkthrough](https://player.vimeo.com/video/337176350)
- [ ] 23. [What is Privilege?](https://www.buzzfeed.com/nicolaharvey/what-is-privilege)
- [ ] 24. [What is Intersectionality?](https://time.com/5560575/intersectionality-theory/)
- [ ] 25. [12 Things Allies Can Do](https://blog.techinclusion.co/tech-diversity-12-things-an-ally-can-do-ca5c93435d26)
- [ ] 26. [How Do I Ally?](https://medium.com/@hadrad1000/how-do-i-ally-being-an-ally-to-women-in-technology-73b70fb86a98)
- [ ] 27. [Getting Started in Social Justice](https://modelviewculture.com/pieces/getting-started-in-techs-social-justice-movement)
- [ ] 28. [SQL Introduction Lecture](https://player.vimeo.com/video/337179947)
- [ ] 29. [Case, Coalesce, & Sub Queries Lecture](https://player.vimeo.com/video/337185831)
- [ ] 30. [GROUP BY & HAVING Lecture](https://player.vimeo.com/video/337188790)
- [ ] 31. [LEFT OUTER JOIN & Join Tables](https://player.vimeo.com/video/337190994)
- [ ] 32. [SQL Zoo](projects/sqlzoo/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/sqlzoo/solution.zip)
- [ ] 33. [Optimized SQL: SQL Cats](projects/sql_cats/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/sql_cats/solution.zip)
- [ ] 34. [Video solution to Julie Andrews query](https://player.vimeo.com/video/184539804)
- [ ] 35. [Joins Video solution to Julie Andrews Query](https://player.vimeo.com/video/337176404)
- [ ] 36. [Video solution to Craiglockhart to Sighthill query](https://player.vimeo.com/video/184539167)
## Object Relational Model
- [ ] 1. [RDBMS Intro](https://player.vimeo.com/video/167596295)
- [ ] 2. [Building a Database](https://player.vimeo.com/video/167593816)
- [ ] 3. [ORM Intro](https://player.vimeo.com/video/167805228)
- [ ] 4. [ORM Demo](https://player.vimeo.com/video/167672029)
- [ ] 5. [SQLite3](readings/sqlite3.md)
- [ ] 6. [Heredocs](readings/heredocs.md)
- [ ] 7. [Little Bobby Tables](http://xkcd.com/327/)
- [ ] 8. [CSS Box Model Reading](../html-css/readings/box_model.md)
- [ ] 9. [CSS Display Property Reading](../html-css/readings/display.md)
- [ ] 10. [CSS Inherits](https://player.vimeo.com/video/151190179)
- [ ] 11. [CSS Reset](https://player.vimeo.com/video/151190181)
- [ ] 12. [CSS Positioning](../html-css/readings/positioning.md)
- [ ] 13. [CSS Float and Clearfix](https://player.vimeo.com/video/151190182)
- [ ] 14. [CSS Float and Clearfix Reading](../html-css/readings/floats_clear_fix.md)
- [ ] 15. [CSS Flexbox](https://player.vimeo.com/video/170512344)
- [ ] 16. [Flexbox Froggy](https://flexboxfroggy.com/)
- [ ] 17. [CSS Grid System](https://player.vimeo.com/video/170320160)
- [ ] 18. [CSS Grid Garden](http://cssgridgarden.com/)
- [ ] 19. [ORM Quiz](quizzes/sql_ii.md)
- [ ] 20. [Plays-Playwrights ORM](homeworks/plays/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/homeworks/plays/solution.zip)
- [ ] 21. [Shakshuka Part 2](../html-css/micro-projects/shakshuka/README.md)
- [Solution](https://assets.aaonline.io/fullstack/html-css/micro-projects/flex/solution.zip)
- [ ] 20. [AA Questions](../sql/projects/aa_questions/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/aa_questions/solution.zip)
- [ ] 21. [a/A Questions Solutions](https://player.vimeo.com/video/337186431)
## Active Record
- [ ] 1. [Nontechnical Overview of Rails](../rails/readings/rails_nontech.md)
- [ ] 2. [Starting a new Rails Project](https://player.vimeo.com/video/331844969)
- [ ] 3. [Migrations Overview](readings/migrations-overview.md)
- [ ] 4. [Migrations Intro](https://player.vimeo.com/video/332280097)
- [ ] 5. [Making Migrations](https://player.vimeo.com/video/334352149)
- [ ] 6. [Changing Migrations](https://player.vimeo.com/video/334402682)
- [ ] 7. [Rollbacks](readings/rails-rollbacks.md)
- [ ] 8. [ORM Overview](readings/orm-overview.md)
- [ ] 9. [Models](https://player.vimeo.com/video/334409696)
- [ ] 10. [Validations](https://player.vimeo.com/video/334438467)
- [ ] 11. [Basic Associations (belongs_to, has_many)](https://player.vimeo.com/video/337298102)
- [ ] 12. [More Associations (has_many through:...)](https://player.vimeo.com/video/338893305)
- [ ] 13. [Validations Overview](readings/validations-overview.md)
- [ ] 14. [Indices Overview](readings/indexing-overview.md)
- [ ] 15. [Indices](https://player.vimeo.com/video/338922220)
- [ ] 16. [Introduction Rails Quiz](quizzes/intro_rails.md)
- [ ] 17. [Intro to Rails](homeworks/intro_rails/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/homeworks/intro_rails/solution.zip)
- [ ] 18. [Association Flowchart](readings/association-flowchart.md)
- [ ] 19. [Creating a new Rails project](readings/first-rails-project.md)
- [ ] 20. [Migrations Reading](readings/migrations.md)
- [ ] 21. [ORM Review and Intro to Active Record](readings/orm.md)
- [ ] 22. [Associations: belongs_to and has_many](readings/belongs-to-has-many.md)
- [ ] 23. [Associations: has_many :through](readings/has-many-through.md)
- [ ] 24. [Associations: has_one](readings/has-one.md)
- [ ] 25. [Unconventional Associations](readings/unconventional-associations.md)
- [ ] 26. [Basic Validations](readings/validations.md)
- [ ] 27. [Custom Validations](readings/custom-validations.md)
- [ ] 28. [Miscellaneous Validations](readings/validations-misc.md)
- [ ] 29. [ActiveRecord Indexes and Uniqueness](readings/indexing.md)
- [ ] 30. [Intro to Rails & Migrations Lecture](https://player.vimeo.com/video/337190478)
- [ ] 31. [Intro to Rails Models Lecture](https://player.vimeo.com/video/337195514)
- [ ] 32. [Associations Lecture](https://player.vimeo.com/video/337196481)
- [ ] 33. [Validations Lecture](https://player.vimeo.com/video/337197006)
- [ ] 34. [Associations Exercise](projects/associations_exercise/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/associations_exercise/solution.zip)
- [ ] 35. [Url shortener](projects/url_shortener/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/url_shortener/solution.zip)
## Active Record II
- [ ] 1. [ActiveRecord::Relation](readings/relation.md)
- [ ] 2. [ActiveRecord and Joins](readings/joins.md)
- [ ] 3. [N Plus One](readings/n_plus_one.md)
- [ ] 4. [Scopes](readings/scopes.md)
- [ ] 5. [More on Querying](readings/querying-ii.md)
- [ ] 6. [Active Record Quiz](quizzes/active_record.md)
- [ ] 7. [Movie Buff in Training](homeworks/movie_buff/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/homeworks/active_record_warmup/solution.zip)
- [ ] 8. [N+1 Buster](homeworks/n_1_buster/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/homeworks/n_1_buster/solution.zip)
- [ ] 9. [Includes vs Joins: Whats the difference?](http://tomdallimore.com/blog/includes-vs-joins-in-rails-when-and-where/)
- [ ] 10. [Ternary Logic in SQL](readings/sql-ternary-logic.md)
- [ ] 11. [Rails 1 Practice](https://appacademy-open-assets.s3-us-west-1.amazonaws.com/fullstack/rails/assets/rails1-practice.zip)
- [Solution](https://appacademy-open-assets.s3-us-west-1.amazonaws.com/fullstack/rails/assets/rails1-practice-solution.zip)
- [ ] 12. [Rails 1 Practice - Initial Setup](https://player.vimeo.com/video/428154587)
- [ ] 13. [Rails 1 Practice - Associations](https://player.vimeo.com/video/428157631)
- [ ] 14. [Rails 1 Practice - Migrations](https://player.vimeo.com/video/428158038)
- [ ] 15. [Rails 1 Practice - Active Record](https://player.vimeo.com/video/428156379)
- [ ] 16. [Rails 1 Practice - SQL](https://player.vimeo.com/video/428158396)
- [ ] 17. [Association Methods Lecture](https://player.vimeo.com/video/337176449)
- [ ] 18. [Association Methods Lecture - Part Two](https://player.vimeo.com/video/337183331)
- [ ] 19. [Association Methods Lecture - Part Three](https://player.vimeo.com/video/337188109)
- [ ] 20. [Movie Buff](projects/movie_buff/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/movie_buff/solution.zip)
- [ ] 21. [Polls](projects/polls_app/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/polls_app/solution.zip)
- [ ] 22. [Polls App Solutions](https://player.vimeo.com/video/337176520)
## Active Record under-the-hood
- [ ] 1. [Metaprogramming](readings/metaprogramming.md)
- [ ] 2. [Class Instance Variables](readings/class-instance-variables.md)
- [ ] 3. [Demo: send](demos/send.md)
- [ ] 4. [Demo: macros](demos/macros.md)
- [ ] 5. [Metaprogramming Quiz](quizzes/meta.md)
- [ ] 6. [Metacorgis](homeworks/meta_corgis/README.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/homeworks/meta_corgis/solution.rb)
- [ ] 7. [Metaprogramming Intro Lecture](https://player.vimeo.com/video/337185643)
- [ ] 8. [Metaprogramming Class Variables Lecture](https://player.vimeo.com/video/337187609)
- [ ] 9. [Metaprogramming Instance Variables Lecture](https://player.vimeo.com/video/337188930)
- [ ] 10. [define_method & method_missing Lecture](https://player.vimeo.com/video/337190496)
- [ ] 11. [Build Your Own ActiveRecord Part 1](projects/active_record_lite/instructions/active-record-lite-i.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/active_record_lite/solution.zip)
- [ ] 12. [Build Your Own ActiveRecord Part 2](projects/active_record_lite/instructions/active-record-lite-ii.md)
- [Solution](https://assets.aaonline.io/fullstack/sql/projects/active_record_lite/solution.zip)
71 changes: 71 additions & 0 deletions sql/homeworks/intro_rails/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Intro To Rails Homework

**Create a simple Rails project and try out what you've learned so far!**

In this project you'll be creating a simple Rails project to model the
relationships between people and houses. By the end of this project, each
`Person` will live in a house, and each `House` will have an `address`. You will
be able to call `#residents` on a `House` instance and get a list of the
people that live in that house. You will also be able to call `#house` on a
`Person` instance and get the house where that person lives.

**Pro Tip**: Refer to the readings **often**!

## Phase 1: `rails new`

- Create a new rails project using PostgreSQL.
- Remember to use the `-G`, `-T`, `--minimal`, and `-d=postgresql` flags when
creating your project!
- Remember to change `debug` to `byebug` and add `pry-rails` and `annotate` in
your __Gemfile__ (then `bundle install`)!
- Since you used the `-G` flag, Rails will not create the __.gitattributes__
and **.gitignore** files. You can grab those two files from the starter repo
at the `Download Project` button below. Copy them into the root directory of
your project.
- Remember to create the database!
- Remember that you need to have Postgres running in the background!

## Phase 2: Create Models and Migrations

- Create a `Person` model and a `people` table. Each `Person` should have a
`name` and a `house_id`.
- You will need to create and run a migration for each model. (Refer to the
Migration reading if you need a reminder!)
- You will need to create a file called `<model_name>.rb` in `app/models/` for
each model.
> Replace `<model_name>` with the (singular, lowercase, snake_case) name of
> the model.
- For each model, you should validate the presence of each attribute that the
model can have. (Refer to the Basic Validations reading for an example.)
Remember that Rails handles certain validations for you!
> Hint: Run `bundle exec annotate --models` to install a copy of the
> model's schema at the top of each model file.
- Create a `House` model and a `houses` table. Each `House` should have an
`address`. Add appropriate validations.

## Phase 3: Create associations

- Create associations for `House` and `Person` such that `House`s can have
many `#residents` and each `Person` belongs to a `#house`. (Refer to the
readings for `belongs_to` and `has_many` for help.)
- These associations rely on your specifying the correct `primary_key`,
`foreign_key`, and `class_name`. Otherwise, when you call `#residents` on a
`House` instance, Rails will assume you are following conventions and look
for a `residents` table rather than a `people` table!

## Phase 4: Try it out!

- Use the `rails console`--search for `rails console` in the ORM Review reading
to find out more about it--to create some data and run some basic queries.
- You should be able to run the following:

```ruby
house = House.new(address: '308 Negra Arroyo Lane')
house.save!

person = Person.new(name: 'Walter White', house_id: house.id)
person.save!

Person.first.house # House with address: "308 Negra Arroyo Lane"
House.first.residents # array containing Person with name: "Walter White"
```
7 changes: 7 additions & 0 deletions sql/homeworks/movie_buff/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
26 changes: 26 additions & 0 deletions sql/homeworks/movie_buff/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep


/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key
3 changes: 3 additions & 0 deletions sql/homeworks/movie_buff/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--require spec_helper
--color
--format documentation
1 change: 1 addition & 0 deletions sql/homeworks/movie_buff/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.1
32 changes: 32 additions & 0 deletions sql/homeworks/movie_buff/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.1"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.3"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "byebug", platforms: %i[ mri mingw x64_mingw ]
gem "rspec-rails"
end

group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
gem "annotate"
gem "pry-rails"
end
Loading