Big Data Orientation: Lab 2 - Working With A Relational Database in Microsoft Azure
Big Data Orientation: Lab 2 - Working With A Relational Database in Microsoft Azure
Overview
Azure SQL Database is a cloud service based on the Microsoft SQL Server relational database
management system (RDBMS). Application developers can use Azure SQL Database as a relational store
for application data, which can be used in big data solutions. In addition to Azure SQL Database, Azure
includes a data warehouse service named Azure SQL Data Warehouse, which shares the same core
database engine as Azure SQL Database but is optimized for large data workloads, and often provides an
analytical data store into which big data processing solutions load the processed data for analysis and
reporting.
In this lab, you will provision and work with Azure SQL Database. The tasks you will perform in this
exercise can also be performed with Azure SQL Data Warehouse.
Important: Before you can perform the lab exercises, you must complete the previous lab in this course.
Query a Table
A relational database contains tables, each of which contains data. Tables are organized into namespaces
called schemas – in the case of the AdventureWorksLT sample database, most of the tables are defined
within a schema named SalesLT.
You can query tables using Transact-SQL to retrieve the data they contain.
3. When prompted, enter the server username and password to log in, then click OK.
4. In the query editor, enter the following Transact-SQL query to retrieve the contents of the
SalesLT.Product table in the AdventureWorksLT database:
Create a Table
The sample database contains many tables, and you can add your own by using the Transact-SQL CREATE
TABLE statement.
1. In the Query pane, replace the existing SELECT statement with the following code:
CREATE TABLE SalesLT.ProductReview
( ProductReviewID INTEGER PRIMARY KEY,
ProductID INTEGER REFERENCES SalesLT.Product(ProductID),
ReviewerName NVARCHAR(25),
ReviewDate DATETIME,
EmailAddress NVARCHAR(50),
Rating INTEGER,
Comments NTEXT );
4. Click Run, and verify that the query succeeds but returns 0 rows.
5. Close the query editor without saving any changes.
1. In the Microsoft Azure portal, in the menu, click New. Then in the Analytics menu, click Data
Factory. Data Factory can also be found within the Integration menu.
2. In the New data factory blade, enter the following settings, and then click Create:
• Name: Enter a unique name (and make a note of it!)
• Subscription: Select your Azure subscription
• Resource Group: Select the resource group you created previously
• Version: 2
• Location: Select the same region as the Azure SQL Database and server created earlier.
• Pin to dashboard: Unselected
3. View Notifications to verify that deployment has started. Then wait for the data factory to be
deployed (this can take a few minutes.)
4. Click All Resources, and then click your data factory, and click the Author & Monitor tile. This
opens a new tab in your browser.
5. On the new browser tab, click the Copy Data icon in the Let’s Get Started section.
6. On the Properties page of the Copy Data wizard, enter the following details and then click Next:
• Task name: Load Reviews
• Task description: Load review data into Azure SQL Database
• Task cadence (or) Task schedule: Run once now
7. On the Source data store page, notice a number of tabs, such as All, Azure, Database, File, and
more.
8. on the Connect to a Data Store tab, select the Azure, then click + Create new connection.
9. In the New Linked Service dialog, select Azure Blog Storage, and click Continue.
10. Configure the Azure Blog Storage Linked Service as follows, then click Finish:
• Name: BlobStorage_LS
• Description: Copying review data to Azure SQL DB
• Connect via integration runtime: AutoResolveIntegrationRuntime
• Authentication method: Use account key w / Connection String
• Account selection method: From Azure subscription
• Azure subscription: Select the appropriate Azure subscription
• Storage account name: Select the storage account name created in the first lab.
11. On the Source Data Store page, click Next.
12. On the Choose the inpt file or folder page, click Browse.
13. Double click on the bigdata folder you created in the previous lab, then double click on the
reviews.txt file to select the file (or select the reviews.txt file and click Choose), then click Next.
14. On the File format settings page, wait a few seconds for the data to be read, and then verify the
following details, ensuring that the rows of data in the Preview section match the table below,
and click Next:
• File format: text format
• Column delimiter: Tab (\t)
• Row delimiter: Carriage return and line feed (\r\n)
• Skip line count: 0
• Column names in first data row: Selected
15. Select the Advanced option, and configure the following:
• Treat empty column value as null: Selected
16. Click Next.
17. On the Destination data store page, select the Azure option, then click + Create new
connection.
18. In the New Linked Service dialog, select Azure SQL Database, then click Continue.
19. Configure the Azure SQL database Linked Service as follows, then click Finish:
• Name: SQLDatabase_LS
• Description: Linked service to Azure SQL Database AdventureWorksLT
• Connect via Integration runtime: AutoResolveIntegrationRuntime / Connection String
• Account selection method: From Azure Subscription
• Azure subscription: Select your subscription
• Server name: Select your Azure SQL server • Database name: AdventureWorksLT
• Authentication type:
• User name: The server admin login name you specified when creating the database
• Password: The password for your Azure SQL server admin login
20. On the Destination data store page, click Next.
21. On the Table mapping page, in the Destination list, select [SalesLT].[ProductReview] and click
Next.
22. On the Schema mapping page, ensure that the following settings are selected, and click Next:
2. On the AdventureWorksLT blade, view the Data Explorer page. This opens the web-based query
interface for your Azure SQL Database.
3. In the toolbar for the query editor, click Login, and then log into your database using SQL Server
authentication and entering the login name and password you specified when provisioning the
Azure SQL Database server.
4. In the query editor, enter the following Transact-SQL query to retrieve the contents of the
SalesLT.ProductReview table in the AdventureWorksLT database: