Checkpoints
Create Instance
/ 20
Create Database
/ 20
Create and Load Tables
/ 20
Load Customer table
/ 20
Add Column
/ 20
Create and Manage Cloud Spanner Databases: Challenge Lab
- GSP381
- Overview
- Scenario
- Objectives
- Target Audience
- Setup and Requirements
- Task 1. Create a Cloud Spanner instance
- Task 2. Create a Cloud Spanner database
- Task 3. Create tables in your database
- Task 4. Load simple datasets into tables
- Task 5. Load a complex dataset
- Task 6. Add a new column to an existing table
- Congratulations!
GSP381
Overview
In this challenge lab, lab you are given a set number of tasks to perform. These have all been covered in the quest Create and Manage Cloud Spanner Databases. You will not be given step-by-step instructions, but you will be given certain directives which you must follow, such as the naming of certain resources, or some guidelines about how you should solve the problems.
Scenario
In your role as the corporate Database Administrator you have been tasked with standing up a new Cloud Spanner database for your company's Banking Operations group. You have been provided a list specifcations for this database related to tables datasets to load.
Objectives
In this challenge lab, you are required to perform the following tasks:
- Create a Cloud Spanner instance.
- Create a Cloud Spanner database.
- Create a tables in your database.
- Load simple datasets into tables
- Load a complex dataset.
- Add a new column to an existing table.
Target Audience
The content of this challenge lab will be most applicable to Cloud Spanner DBAs. This lab is designed to test the abilities of students who have completed the Create and Manage Cloud Spanner Databases quest.
Setup and Requirements
Qwiklabs setup
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.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
Cloud Console
How to start your lab and sign in to the Google Cloud console
-
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 the Lab Details panel with the following:
- The Open Google Cloud console button
- Time remaining
- The temporary credentials that you must use for this lab
- Other information, if needed, to step through this lab
-
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account. -
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}} You can also find the Username in the Lab Details panel.
-
Click Next.
-
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}} You can also find the Password in the Lab Details panel.
-
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges. -
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 Google Cloud console opens in this tab.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
- Click Activate Cloud Shell at the top of the Google Cloud console.
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
- Click Authorize.
Output:
- (Optional) You can list the project ID with this command:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Task 1. Create a Cloud Spanner instance
-
Your first task is to create an instance.
-
You may complete this step using the Cloud Console or the gcloud CLI.
-
Your instance must have following attributes:
Item | Value |
---|---|
Name | banking-ops-instance |
Region | |
Allocate Compute Capacity | Unit - Nodes // Quantity - 1 |
An example gcloud CLI command to create an instance is as follows:
- Click Check my progress to verify the objective.
Task 2. Create a Cloud Spanner database
-
Your next task is to create a database.
-
You may complete this step using the Cloud Console or the gcloud CLI.
-
Your database must have following attribute:
Item | Value |
---|---|
Name | banking-ops-db |
An example gcloud CLI command to create a database is as follows:
- Click Check my progress to verify the objective.
Task 3. Create tables in your database
-
Your database must have a total of four (4) tables - Portfolio, Category, Product, and Customer.
-
The tables must be defined as listed below.
An example DDL command to create a table is as follows:
Table: Portfolio
Primary Key: PortfolioId
Column | Datatype |
---|---|
PortfolioId | INT64 NOT NULL |
Name | STRING(MAX) |
ShortName | STRING(MAX) |
PortfolioInfo | STRING(MAX) |
Table: Category
Primary Key: CategoryId
Column | Datatype |
---|---|
CategoryId | INT64 NOT NULL |
PortfolioId | INT64 NOT NULL |
CategoryName | STRING(MAX) |
PortfolioInfo | STRING(MAX) |
Table: Product
Primary Key: ProductId
Column | Datatype |
---|---|
ProductId | INT64 NOT NULL |
CategoryId | INT64 NOT NULL |
PortfolioId | INT64 NOT NULL |
ProductName | STRING(MAX) |
ProductAssetCode | STRING(25) |
ProductClass | STRING(25) |
Table: Customer
Primary Key: CustomerId
Column | Datatype |
---|---|
CustomerId | STRING(36) NOT NULL |
Name | STRING(MAX) NOT NULL |
Location | STRING(MAX) NOT NULL |
Task 4. Load simple datasets into tables
-
Three of your tables, Portfolio, Category, and Product, will be loaded with simple, low-volume datasets.
-
You may employ any method to load these tables.
An example DML command to load a single row into a table is as follows:
Table: Portfolio
Table: Category
Table: Product
- Click each Check my progress to verify the objectives.
Task 5. Load a complex dataset
-
You will load the Customer table with a much larger set of data.
-
A file named Customer_List_500.csv contains 500 rows of data and is located in the following public Cloud Storage bucket. You may reference or download it as necessary.
gsutil URI
HTTP URL
-
You may recall from the lab Cloud Spanner - Loading Data and Performing Backups that a few options exist to load larger datasets. These include using Dataflow or a client library in Batch mode. You may choose to create simple insert statements. The decision is yours but you must load all 500 rows.
-
Utilize any method that you prefer to load the 500 row datafile. Some methods will require edits to the datafile which will require downloading it to your local machine. Please be sure to make a backup file if you choose that option.
-
Note: if you use Dataflow should ensure that you specify the
Regional Endpoint and reset the Dataflow API via the following gcloud command:
- Also if you use a Dataflow template you will be required to provide a Mainfest file named manifest.json. Below is a sample manifest.json that you can use to guide creation of a file appropriate for loading the Customer table.
Note:
- Click Check my progress to verify the objective.
Task 6. Add a new column to an existing table
-
As part of your DBA responsibilities you are required to add a new column called MarketingBudget to the Category table.
-
The column MarketingBudget must have a datatype of INT64.
-
Adding a new column is accomplished by a DDL command. You may issue the DDL via a gcloud command, the Cloud Console, or client library call.
An example gcloud CLI command to add a column to a table is as follows:
- Click Check my progress to verify the objective.
Congratulations!
You have completed the Create and Manage Cloud Spanner Databases: Challenge Lab! In this lab, you created a Cloud Spanner instance and database, created tables, loaded data, and performed DDL operations on a table. You have earned the following skill badge.
Earn Your Next Skill Badge
This self-paced lab is part of the Create and Manage Cloud Spanner Databases quest. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge 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 this quest and get immediate completion credit if you have successfully completed this lab.
Search for other available quests in the Cloud Skills Boost catalog.
Manual Last Updated: August 31, 2023
Lab Last Tested: August 31, 2023
Copyright 2024 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.