Egghead Instructor Brett Cassette

Brett Cassette

Brett is a comedian and writer who has heard of, but never truly experienced, programming



Unlock all of Brett's PRO Lessons
click for instant access!

Browse Brett Cassette's lessons.

showing 59 lessons...

Find Related Data with Inner Join in Postgres

P

Detect Duplicates in Postgres with Cartesian Product

P

Use Joins to Detect Orphaned Data in Postgres

P

Create a History Table in Postgres with Joins

P

Join Tables in Postgres with Complex Conditions

P

Find Lonely Postgres Data with Left and Right Join

See All Rows from Different Postgres Tables with Union All

P

Find Postgres Data That Doesn’t Match Join Conditions with Full Outer Join

Combine Window Functions to Answer Complex Questions

P

Compare the Outliers Using First Value and Last Value

P

Compare Related Rows Using Lag and Lead

P

Understand Frame Clauses

P

Create Running Totals Using Window Functions

P

Find Percentiles Using ntile

P

Define Windows Using Multiple Factors

P

Perform Weighted Ranking with Percent Rank

P

Rank Records with Rank and Dense Rank

P

Learn What A Window Function Can Do

P

Select Distinct Data in Postgres

P

Speed Up Postgres Queries with Indexes

P

Find Intersecting Data with Postgres’ Inner Join

P

Enforce Custom Logic with Check Constraints in Postgres

P

Create Foreign Keys Across Multiple Fields in Postgres

P

Use Foreign Keys to Ensure Data Integrity in Postgres

P

Sort Postgres Tables

P

Ensure Uniqueness in Postgres

P

Filter Data in a Postgres Table with Query Statements

P

Group and Aggregate Data in Postgres

P

Update Data in Postgres

P

Delete Postgres Records

P

Insert Data into Postgres Tables

P

Create a Postgres Table

P

Serializing and Deserializing Data Models in AngularJS

P

Refactoring: Replace Loop with Collection Closure using Lodash

P

Refactoring: Polymorphic Functions

P

Refactoring: Extract Method

P

Refactoring: Unit Test Coverage Report Setup

P

Basic Metaprogramming: Dynamic Method

P

Finishing Validatable

P

Errorable Mixin

Mixing in Validatable

P

Validations Class

P

Adding Child Validators

P

Basic Implementation of Configurable Validations

P

Model Validation Design Review

Refactor The Model Base Class with Mixins

P

Search Directive with Rails

P

JavaScript Function Scope and $scope

P

Advanced Function Scope

P

JavaScript Function Scope Basics

P
postgres tutorial about Find Related Data with Inner Join in Postgres

Find Related Data with Inner Join in Postgres

2:52 postgres PRO

In this lesson, we’ll learn how to relate data on a condition that exists in multiple tables. The inner join will help us answer the question “Which users have backed our Kickstarter project?” We’ll also see what join conditions are all about.

postgres tutorial about Detect Duplicates in Postgres with Cartesian Product

Detect Duplicates in Postgres with Cartesian Product

1:11 postgres PRO

The cartesian product is a humdinger -- it relates all data in one table to all data in another! Now that’s a lot of rows, and fast. Surprisingly, cartesian products are as fast as inner joins at duplicate detection, thanks to the magic of the query planner!

postgres tutorial about Use Joins to Detect Orphaned Data in Postgres

Use Joins to Detect Orphaned Data in Postgres

2:02 postgres PRO

Unfortunately, sometimes we don’t add the right constraints to our data. A user gets deleted and old data doesn’t get cleaned up. Primary information is deleted, but its audit trail isn’t. With left and right joins, we can flag anomalous data for deletion.

postgres tutorial about Create a History Table in Postgres with Joins

Create a History Table in Postgres with Joins

2:22 postgres PRO

Possibly my favorite data management trick is the history table. With history tables, we record all changes in two locations -- once in the primary table (as an update), and once in a history table (as an insert). With this handy trick, we save an audited record of all data, when it was live, and who changed it and when. Coupled with non-destructive deletes, you can explore the complete history of your data with joins.

postgres tutorial about Join Tables in Postgres with Complex Conditions

Join Tables in Postgres with Complex Conditions

2:38 postgres PRO

While our data is sometimes nicely managed with surrogate primary key joins, often times older tables can feature join conditions with complex natural keys.

postgres tutorial about Find Lonely Postgres Data with Left and Right Join

Find Lonely Postgres Data with Left and Right Join

1:59 postgres

How can we find out which Kickstart projects have no backers? Or which backers have not backed any projects? Left and right join can answer these questions.

postgres tutorial about See All Rows from Different Postgres Tables with Union All

See All Rows from Different Postgres Tables with Union All

1:16 postgres PRO

By default, union removes duplicate rows in the combined table. Union all, however, leaves all rows intact.

postgres tutorial about Find Postgres Data That Doesn’t Match Join Conditions with Full Outer Join

Find Postgres Data That Doesn’t Match Join Conditions with Full Outer Join

1:14 postgres

What if we want to see all Kickstarter projects with backers, plus projects that have no backers, plus backers that have no projects? We can use full outer join for that. In the wild, full outer join, left join, and right join will most often be used for orphan detection.

postgres tutorial about Combine Window Functions to Answer Complex Questions

Combine Window Functions to Answer Complex Questions

3:38 postgres PRO

Individual window functions are useful, but sometimes you’ll need to combine them to answer complex questions. For instance, which 10 star movies were released in the year that had the most 10 star movies released?

postgres tutorial about Compare the Outliers Using First Value and Last Value

Compare the Outliers Using First Value and Last Value

1:55 postgres PRO

How does each runner compare with the first and last place finisher? What about the nth place finisher? Firstvalue, lastvalue, and nth_value can make these decisions.

postgres tutorial about Compare Related Rows Using Lag and Lead

Compare Related Rows Using Lag and Lead

2:16 postgres PRO

If you have a list of competitors and their finishing times, how do you determine how much time separated each competitor? Lag and lead allow you to compare rows in order -- for instance, comparing the 1st and 2nd place finishers and the 2nd and 3rd place finishers.

postgres tutorial about Understand Frame Clauses

Understand Frame Clauses

2:00 postgres PRO

What if you want aggregations that aren’t running totals? What if you want the sum total for the whole frame? Or the minimum value across the frame? Unbounded preceding, unbounded following, and current row help you define your frame of reference.

postgres tutorial about Create Running Totals Using Window Functions

Create Running Totals Using Window Functions

1:06 postgres PRO

How could your Kickstarter-type site list the running total for each contribution next to it? Using window functions of course! The default behavior for aggregations under window functions is to create running totals.

postgres tutorial about Find Percentiles Using ntile

Find Percentiles Using ntile

1:44 postgres PRO

What scores do the 90th percentile of students receive? How long does the 99th percentile web request take? Percentiles and arbitrary ntiles provider a richer understanding of underlying data and outliers.

postgres tutorial about Define Windows Using Multiple Factors

Define Windows Using Multiple Factors

1:55 postgres PRO

Weighted ranking on a single factor can hide lots of information. For instance, students without access to internet perform 1-3 full letter grades worse than their peers with internet access. A teacher that wanted to consider student privilege could take many factors into account when assigning student grades to get a better sense for how strong individual students were.

postgres tutorial about Perform Weighted Ranking with Percent Rank

Perform Weighted Ranking with Percent Rank

1:55 postgres PRO

What if you had a list of student grades and wanted to give them a weighted grade for the school year? Percent rank is used to answer frequency distribution questions.

postgres tutorial about Rank Records with Rank and Dense Rank

Rank Records with Rank and Dense Rank

1:35 postgres PRO

If you have a list of competitors in a race, and a list of their finishing times, how do you create a list of what place they came in? Rank and dense rank can help you out; they differ in how they handle ties.

postgres tutorial about Learn What A Window Function Can Do

Learn What A Window Function Can Do

1:47 postgres PRO

In this lesson we’ll see how we can partition movies into the years they were released, and find the top 5 rated titles each year. The power of the window function is to partition data into groups and answer questions about those groups.

postgres tutorial about Select Distinct Data in Postgres

Select Distinct Data in Postgres

0:52 postgres PRO

How many users visited our site yesterday? We can find out by looking at each visit, and limiting this list to a distinct list of users (who may have visited many times). In this lesson we’ll learn how to answer questions like these with the distinct keyword.

postgres tutorial about Speed Up Postgres Queries with Indexes

Speed Up Postgres Queries with Indexes

2:33 postgres PRO

The more data you add, the longer it will take to answer new questions you pose to your database. That’s because so far, Postgres has been scanning through the table looking at every row to see if it meets the constraint. We can speed this process up substantially by adding indexes.

postgres tutorial about Find Intersecting Data with Postgres’ Inner Join

Find Intersecting Data with Postgres’ Inner Join

4:26 postgres PRO

You have a table of movies and a table of directors; how can you see which director created each movie? An inner join will link related records so that you can answer questions like these. Inner joins are the most commonly used SQL join, because they only return data that is common in both tables.

postgres tutorial about Enforce Custom Logic with Check Constraints in Postgres

Enforce Custom Logic with Check Constraints in Postgres

2:07 postgres PRO

What if your tables need custom constraints? A movie should only receive 1-5 stars, never 0 or 6. Price after tax should always equal the sum of the price plus tax. Check constraints help you enforce your own custom logic.

postgres tutorial about Create Foreign Keys Across Multiple Fields in Postgres

Create Foreign Keys Across Multiple Fields in Postgres

3:08 postgres PRO

What if your foreign keys are more complex than a single field? Postgres lets you enforce foreign key constraints across multiple fields with a similar syntax to defining complex primary keys.

postgres tutorial about Use Foreign Keys to Ensure Data Integrity in Postgres

Use Foreign Keys to Ensure Data Integrity in Postgres

2:18 postgres PRO

Every movie needs a director and every rented movie needs to exist in the store. How do we make sure something in another table exists before inserting new data? This lesson will teach us about foreign keys and references.

postgres tutorial about Sort Postgres Tables

Sort Postgres Tables

1:20 postgres PRO

How do I see a list of my Facebook friends sorted by the number of friends they have, and then sorted alphabetically to break ties? Sorting data helps us to answer important business questions. In this lesson, we’ll learn how to do it in Postgres.

postgres tutorial about Ensure Uniqueness in Postgres

Ensure Uniqueness in Postgres

3:53 postgres PRO

Let’s say we have a bank. Our bank wants to give each account for each user a unique name, for instance, “Personal” or “Checking.” How can we make sure each account has a unique name for each user?

postgres tutorial about Filter Data in a Postgres Table with Query Statements

Filter Data in a Postgres Table with Query Statements

3:35 postgres PRO

We have all this data, but how do we answer questions about it? In this lesson we’ll learn how to filter down to just the information we’re looking for.

postgres tutorial about Group and Aggregate Data in Postgres

Group and Aggregate Data in Postgres

6:45 postgres PRO

How can we see a histogram of movies on IMDB with a particular rating? Or how much movies grossed at the box office each month? Or how many movies there are of each genre? These are examples of data aggregation questions, and this lesson will teach us how to answer them.

postgres tutorial about Update Data in Postgres

Update Data in Postgres

1:55 postgres PRO

Data changes. In some applications, it changes all the time! In this lesson we’ll learn how to update a single record or many at once.

postgres tutorial about Delete Postgres Records

Delete Postgres Records

2:43 postgres PRO

What if you no longer need some information? Perhaps your tables are very large and you need to clean up your table to speed it up. This lesson will teach us how to delete data from our database.

postgres tutorial about Insert Data into Postgres Tables

Insert Data into Postgres Tables

4:24 postgres PRO

Learn how to insert one record, two records, a million records! We’ll also explore some edge cases, like where not all data is known at the time of insertion.

postgres tutorial about Create a Postgres Table

Create a Postgres Table

1:45 postgres PRO

Learn how to create a table using the most widely-used data types (serial, varchar, integer, float, boolean, and date), and the most necessary constraints (NOT NULL and primary key).

angularjs tutorial about Serializing and Deserializing Data Models in AngularJS

Serializing and Deserializing Data Models in AngularJS

7:34 angularjs PRO

It is important to have consistent data for your application to use. To achieve this, our modeling library will need to have the ability to serialize and deserialize data received into a format it understands, plain old JavaScript objects.

This lesson is part of a series on building a robust modeling layer in your AngularJS applications.

angularjs tutorial about Refactoring: Replace Loop with Collection Closure using Lodash

Refactoring: Replace Loop with Collection Closure using Lodash

6:49 angularjs PRO

Logic often gets added to our loops. We need to iterate over a collection, and get the sum of values, for instance. This approach can lead to complicated methods, that are hard to test. Using Lodash (Underscore), we are going to extract logic in a large loop body into well named methods. The result will be cleaner and easier to understand.

angularjs tutorial about Refactoring: Polymorphic Functions

Refactoring: Polymorphic Functions

4:37 angularjs PRO

if-statements can add serious complexity and beg for refactoring. You can use polymorphic functions to simplify your ifs and dynamically call the appropriate method.

angularjs tutorial about Refactoring: Extract Method

Refactoring: Extract Method

8:15 angularjs PRO

Refactoring is a fact of life, and the "extract method" refactoring is the cornerstone of improving your code.

angularjs tutorial about Refactoring: Unit Test Coverage Report Setup

Refactoring: Unit Test Coverage Report Setup

5:42 angularjs PRO

The "R" word. Refactoring. The first step in refactoring code is to make sure we are covering the existing code with tests. If we aren't refactoring against tested code, we are just changing stuff. In this lesson, we'll start taking a look at some code that needs refactoring, and get test coverage reports setup.

js tutorial about Basic Metaprogramming: Dynamic Method

Basic Metaprogramming: Dynamic Method

4:27 js PRO

Metaprogramming is a powerful tool for dynamically applying behavior to JavaScript objects. It can be a confusing concept, "code that writes code", but is very useful when you understand a few simple concepts. This lesson will show you how to create dynamic methods on your Javascript objects.

angularjs tutorial about Finishing Validatable

Finishing Validatable

13:13 angularjs PRO

We can now finalize the Validatable piece of our data modeling library.

This lesson is part of a series. Be sure to watch the previous lessons to fully understand what is going on!

angularjs tutorial about Errorable Mixin

Errorable Mixin

11:08 angularjs

Now that we have validations, we will want to be able to provide the user feedback on the errors in models. This is useful for forms, and is a critical part of the validation process.

This lesson is part of a series!

angularjs tutorial about Mixing in Validatable

Mixing in Validatable

12:07 angularjs PRO

Now that the validation component has progressed, we can start mixing it in for usage.

This video is a part of a series, you'll want to watch the earlier lessons before this one.

angularjs tutorial about Validations Class

Validations Class

2:16 angularjs PRO

Now we bring the validations together with a Validations class.

angularjs tutorial about Adding Child Validators

Adding Child Validators

9:30 angularjs PRO

To make our AngularJS data model validation more robust, we want the ability to make complex validators that have child validators.

angularjs tutorial about Basic Implementation of Configurable Validations

Basic Implementation of Configurable Validations

9:08 angularjs PRO

With the roadmap set, we will start to implement configurable validations for our Models.

angularjs tutorial about Model Validation Design Review

Model Validation Design Review

7:31 angularjs

We want robust validation for our AngularJS models. This will require a bit of forethought, and this lesson will examine the goals that we have for the validation piece of our model library.

angularjs tutorial about Refactor The Model Base Class with Mixins

Refactor The Model Base Class with Mixins

11:20 angularjs PRO

We've built a base class that is starting to sprawl, and now we want to unit test and refactor out the caching logic into a mixin that will handle this functionality.

This lesson is part of a series.

angularjs tutorial about Search Directive with Rails

Search Directive with Rails

7:35 angularjs PRO

Create a search directive with AngularJS and Rails. You'll want to take a look at the related Rails TODO API Part 1 and Rails TODO API Part 2. This is not a Rails how-to, so some knowledge there is expected to get up and running.

angularjs tutorial about JavaScript Function Scope and $scope

JavaScript Function Scope and $scope

6:57 angularjs PRO

How does AngularJS $scope relate to JavaScript function scope?

js tutorial about Advanced Function Scope

Advanced Function Scope

7:06 js PRO

Function scope and closures in JavaScript can be tricky. This lesson builds on the Function Scope Basics video to dive deeper into JS function scope.

js tutorial about JavaScript Function Scope Basics

JavaScript Function Scope Basics

5:45 js PRO

This or that? Javascript scoping can be confusing. This lesson covers the very basics of function scoping.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?