arrow_back

Exploring NCAA Data with BigQuery

Join Sign in

Exploring NCAA Data with BigQuery

45 minutes 5 Credits

GSP160

Google Cloud Self-Paced Labs

Overview

BigQuery is Google's fully managed, NoOps, low cost analytics database. With BigQuery you can query terabytes and terabytes of data without managing infrastructure or needing a database administrator. BigQuery uses SQL and takes advantage of the pay-as-you-go model. BigQuery allows you to focus on analyzing data to find meaningful insights.

We have a newly available dataset for NCAA Basketball games, teams, and players. The game data covers play-by-play and box scores back to 2009, as well as final scores back to 1996. Additional data about wins and losses goes back to the 1894-5 season in some teams' cases.

In this lab we will find and query the NCAA dataset using BigQuery.

What you'll learn

  • Using BigQuery

  • Query the NCAA Public Dataset

  • Writing and executing queries

What you'll need

Setup and Requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

What you need

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
  • Time to complete the lab.

Note: If you already have your own personal Google Cloud account or project, do not use it for this lab.

Note: If you are using a Chrome OS device, open an Incognito window to run this lab.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.

    Open Google Console

  2. Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Sign in

    Tip: Open the tabs in separate windows, side-by-side.

  3. In the Sign in page, paste the username that you copied from the left panel. Then copy and paste the password.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Training credentials. If you have your own Google Cloud account, do not use it for this lab (avoids incurring charges).

  4. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Open BigQuery Console

In the Google Cloud Console, select Navigation menu > BigQuery:

BigQuery_menu.png

The Welcome to BigQuery in the Cloud Console message box opens. This message box provides a link to the quickstart guide and the release notes.

Click Done.

The BigQuery console opens.

Bigquery-UI.png

BigQuery opens, but there's nothing in here! Luckily, there are tons of Open Datasets available in BigQuery for you to query, and of course you can upload your own data, which you'll do in the next section.

Find the NCAA public dataset in BigQuery

In this section, you pull in some public data so you can practice running SQL commands in BigQuery. Click on the + ADD DATA link then select Explore public datasets:

BQ_UI_Add_Data.png

Type "ncaa basketball" in the searchbar and press Enter.

Click on the NCAA Basketball tile, then View Dataset.

A new browser tab opens, you now have a new project called bigquery-public-data added to the Explorer panel, opened to ncaa_basketball:

BQ_UI_2_proj.png

Click on the dataset name to view the tables you can explore.

BQ_ncaa_tables2.png

Click on mbb_teams_games_sr (men's NCAA game results table) and then click Preview tab to see sample rows of data. Click the Details tab to get metadata about the table.

BQ_UI_Details_Preview.png

How many games does the dataset contain? How big is the table?

BQ_UI_ncaa-table-size.png

Answer: The table is about 50 MB and there are over 29k games for us to explore.

But how many individual plays can we analyze?

Hint: click on the mbb_pbp_sr (play-by-play) dataset:

ncaa_mbb_pbp_rs_table.png

Then click Details:

BQ_UI_ncaa_MBB-PBP-SR.png

Answer: Over 4 million individual basketball plays.

Let’s write some SQL to see what types of plays are there for us to explore.

Writing queries

What types of basketball play events are there?

Click + Compose New Query.

Copy and paste the below query into the editor:

#standardSQL SELECT event_type, COUNT(*) AS event_count FROM `bigquery-public-data.ncaa_basketball.mbb_pbp_sr` GROUP BY 1 ORDER BY event_count DESC;

Now click Run.

Looking at your results, how many historical shots were TWOPOINTMADE or FREETHROWMISS?

2pointmadequery.png

Click Check my progress to verify the objective.

Writing queries

Fun queries to run

Which 5 games featured the most three point shots made? How accurate were all the attempts?

Click + Compose New Query and add in the below query:

#standardSQL #most three points made SELECT scheduled_date, name, market, alias, three_points_att, three_points_made, three_points_pct, opp_name, opp_market, opp_alias, opp_three_points_att, opp_three_points_made, opp_three_points_pct, (three_points_made + opp_three_points_made) AS total_threes FROM `bigquery-public-data.ncaa_basketball.mbb_teams_games_sr` WHERE season > 2010 ORDER BY total_threes DESC LIMIT 5;

Click Run.

dc7fff52adf1d350.png

Wow! The Tigers made over 50% of their three point shots on 11-22-2016.

Click Check my progress to verify the objective.

Query 1

Which 5 basketball venues have the highest seating capacity?

Click + Compose New Query and add the below query:

#standardSQL SELECT venue_name, venue_capacity, venue_city, venue_state FROM `bigquery-public-data.ncaa_basketball.mbb_teams_games_sr` GROUP BY 1,2,3,4 ORDER BY venue_capacity DESC LIMIT 5;

Click Run.

cc7db32fe0935e1a.png

Imagine taking a shot with 80,000 people watching you!

Click Check my progress to verify the objective.

Query 2

Which teams played in the highest scoring game since 2010?

Click + Compose New Query and add the below query:

#standardSQL #highest scoring game of all time SELECT scheduled_date, name, market, alias, points_game AS team_points, opp_name, opp_market, opp_alias, opp_points_game AS opposing_team_points, points_game + opp_points_game AS point_total FROM `bigquery-public-data.ncaa_basketball.mbb_teams_games_sr` WHERE season > 2010 ORDER BY point_total DESC LIMIT 5;

Click Run.

77a1cbd4b599a6fe.png

The Bulldogs and Terriers played in a game that scored 258 total points!

Click Check my progress to verify the objective.

Query 3

Since 2015, what was the biggest difference in final score for a National Championship?

Click + Compose New Query and add the below query:

#standardSQL #biggest point difference in a championship game SELECT scheduled_date, name, market, alias, points_game AS team_points, opp_name, opp_market, opp_alias, opp_points_game AS opposing_team_points, ABS(points_game - opp_points_game) AS point_difference FROM `bigquery-public-data.ncaa_basketball.mbb_teams_games_sr` WHERE season > 2015 AND tournament_type = 'National Championship' ORDER BY point_difference DESC LIMIT 5;

Click Run.

d1a579b443ffc2f0.png

The finals games are surprisingly close! The biggest difference was recent in 2018 with a delta of 17 points.

Click Check my progress to verify the objective.

Query 4

Congratulations!

You've learned how to query the NCAA basketball dataset inside of BigQuery. We encourage you to modify the above queries and write your own to further your understanding. Looking for more NCAA query practice? Checkout the GitHub repo here.

719c8c6d1e702eb3.png MarchMadness02_125.png

Finish your Quest

Continue your Quest with Google Cloud Solutions ll: Data and Machine Learning or NCAA® March Madness®: Bracketology with Google Cloud. A Quest is a series of related labs that form a learning path. Completing this Quest earns you the badge above, to recognize your achievement. You can make your badge (or badges) public and link to them in your online resume or social media account. Enroll in a Quest and get immediate completion credit if you've taken this lab. See other available Qwiklabs Quests.

Take your next lab

Continue your quest with, Creating Custom Interactive Dashboards with Bokeh and BigQuery, or check out these suggestions:

Next steps/learn more

Google Cloud Training & Certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated May 21, 2021
Lab Last Tested May 21, 2021

Copyright 2021 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.