CHUAN BI CONG CU VA DATA WAREHOUSE Để thực hiện quá trinh SSIS thi ta cần chuẩn bị và cài đặt các công cụ sau: - Visual Studio Community 2022 - SQL Server Integration Services Project 1
Trang 1ĐẠI HỌC QUOC GIA THANH PHO HO CHI MINH
TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN
BÁO CÁO BÀI TẬP AI.2 Môn học: Kho dữ liệu và OLAP
Đề tài: Xây dựng kho đữ liệu FurnitureStore
Giảng viên hướng dẫn: Đỗ Thị Minh Phụng Nhóm sinh viên thực hiện:
Võ Ngọc Lệ Xuân - 21521692 Bùi Hữu Bằng - 21520151
Chủ Nhật, Ngày 31 Tháng 03 Năm 2024
Trang 21.4 Mô tả chỉ tiết thuộc tính đataset 55-5 TT TỰ 121212 122221211 1g gay 5
2 Mô hình bông tuyẾt - 2 11 ST1 1111121111111 T1 1121111 111111211 tri 6
2.1 Mô tá bảng Dim_Shipmode: - 002002211211 12 112211211 19111111111 11011151811 Hs ca 7 2.2 Mô ta bảng Dim _Product L0 22012111221 1221121 11212111 11111111 1111111011 811111 ky 7 2.3 MO ta bang 8690 7
PO À N3) 0) / /aiaẳIẶIẶỶỒVẢ 7 PO: há) 080 0n 8
2.7 Mô tả bảng Fact 0022010201120 1 1121111111 1111 111111 111111111 TH nen g ky 9
3 Nội dung 15 câu truy vấn -. S1 ST TỰ 5 T1 1 121101 1212 1212 an rry 9
CHƯƠNG 2: TÍCH HỢP DỮ LIỆU VÀO KHO (SSI§) - 2 1 2E S222 1 ren 11
1 CHUAN BI CONG CỤ VÀ DATA WAREHOUSE - 5 St T121 2 ren 11
2 TAO PROJECT SSIS TRONG VISUAL STUDIO 2022 2- 522222212 222222 2x2 12
3 TAO BANG DIM VÀ BẢNG EACT 5c 1222112112111 gen 13 3.1 Xử lý đữ liệu 2 S52 2222222222 2112212 2121212122122 rrrye 13
3.2 Bảng Dim_ Location 5 L0 201121111 1111111 1111111111 11111111111 1119 k1 kg 611191 kkg 20
Trang 33.5 Bang Dim Category cccccccccececeneceeneeenneeeneceeneeceeeeeneeeeeneeeeeeneeeseeeneaeeee ens 30 3.6 Bang Dim_Product 000.000 coc ccccccececeneceeneeceneeenneeeneseeeeceneeeeeneeeeeeneeeeeeneneeeeenaas 34 KV: j)))(0v)(0)0(00(0( (a5 47 3.8 Bảng Fact_ FurnitureSfore - n1 1110111211111 1 11111101110 1119121 1E 111101 1k6 51
Trang 4NHAN XET CUA GIAO VIEN
Trang 6CHUONG 1 GIOI THIEU TONG QUAN VE DU LIEU
1 Giới thiệu về dataset
1.1 Giới thiệu nguồn dữ liệu
- Té€n dataset: Sales for Furniture Store
ez Row ID = A Order ID = 6 Order Date = 6 Ship Date Index Order/ demand ID Date of demand Date of ship
- _ Tác p1ả của bộ dữ liệu này là Zahra' Alaa Tag el-Denn, là một AI developer
- Nguồn sốc của bộ dữ liệu thuộc về chương trình thực tập sinh khoa học máy tinh của
Mentorness(Mentorness Machine Learning Internship) Mentorness là một nền tảng
tuyển dụng dựa trên bằng chứng công việc Đơn vị này đặt mục tiêu hoạt động đó
Trang 7chính là đóng vai cầu nối giữa những ứng cử viên đang tìm kiếm công việc phù hợp với kỹ năng của họ và những công ty gặp khó khăn trong việc tìm kiếm những ứng cử viên thích hợp
- _ Bộ dữ liệu thu thập các thông tin chỉ tiết về việc kinh doanh như thông tin chung của đơn hàng như: Thông tin về khách hàng, loại hình giao hàng, địa chỉ giao hang, va thông tin chi tiết khác như: Chi tiết đơn hàng, doanh số, dữ liệu khuyến mãi của một cửa hàng bán nội thất trone vòng 10 năm trở lại đây
- _ Bộ dữ liệu gồm 2,121 dòng dữ liệu và 21 cột thuộc tính
1.2 Nguồn tải đataset
- Link dataset: https://www.kaggle.com/datasets/zahraaalaatageldein/sales-for- furniture-store
1.3 Hướng chủ đề
Kho đữ liệu theo hướng chủ đề: Kinh doanh
1.4 Mô tả chỉ tiết thuộc tính dataset
STT | Tên thuộc tính Tên đầy đủ Kiểu dữ liệu | Y nghĩa
hàng Nếu như có 2
dòng liên tiếp có dùng một Order ID thì có
nghĩa là đó là 2 sản
phẩm trone cùng một đơn hàng
Trang 8
cua don hang
MM/dd/yyyy
được giao tdi cho bén
chuyển đến cho khách hàng
MM/dd/yyyy
được chọn cho đơn hàng
chuyển có thể nhận I1 trong 4 gia tri sau:
Customer Name Customer Name | Varchar Tén khach hang
State State Varchar Bang
Trang 9
Identification
17 Profit Profit Float Lợi nhuận
2 Mô hình bông tuyết
Trang 10
fact_id int PK order_id varchar FK
date_id int FK
location_id int FK shipmode_id int FK
product_id varchar FK customer_id varchar FK
sales double quantity int discount double profit double
location id int PK city varchar
state varchar
country varchar region varchar
DimDate
id int P
order_date date order_month int order_year int
order_quarter int
ship_date date ship_month int
Trang 112.1 M6 ta bang Dim_Shipmode:
1 SHIPMODE ID Mã phương thức van | int
1 CATEGORY_ID Mã loại sản phẩm int
Trang 12
CUSTOMER _ID Ma khach hang varchar
CUSTOMER NAME Tén khach hang varchar
Trang 132.6 M6 ta bang Dim_Date
3 ORDER MONTH Thang dat hang int
5 ORDER QUARTER Qúy đặt hàng int
8 SHIP_YEAR Nam giao hang int
Trang 14
2.7 Mô ta bang Fact
1 FACT ID Mã bảng sự kiện int
2 ORDER_ID Ma don hang varchar
chuyển
7 CUSTOMER_ID Mã khách hàng varchar
10 DISCOUNT Phan tram khuyén mai double
3 Nội dung 15 câu truy vẫn
1) Cho biết khách hàng có số tiền mua hàng cao nhất trong năm 20172
2) Đưa ra số lượng sản phâm bán ra của từng loại nội thất?
3) Cho biết thông tin khách hàng (Tên khách hàng, Loại khách hàng) đặt hàng nhiều
nhất trong bang Minnesota?
4)_ Hãy đưa ra năm có doanh thu bán hàng cao nhất?
Trang 155) Theo từng tháng, quý, năm hãy liệt kê số đơn hàng được bán và tông giá trị của các đơn hàng đó?
6)_ Hãy đưa ra doanh thu, lợi nhuận, chiết khấu của từng phân loại sản phẩm)
7) Liệt kê những thành phố có phần trăm lợi nhuận trên 30%?
8) Cho biết số tiền cửa hàng đã chiết khấu cho khách hảng trong quý 4 năm 20152
9) Hay dua ra tổng số lượng các sản phẩm (quantity) theo từng bang?
10) Hãy liệt kê thông tin khách hàng và nơi ở của khách hàng có đơn hang mua sản phâm thuộc phân loai tables va chairs?
Trang 16CHUONG 2 TICH HOP DU LIEU VAO KHO (SSIS)
1 CHUAN BI CONG CU VA DATA WAREHOUSE
Để thực hiện quá trinh SSIS thi ta cần chuẩn bị và cài đặt các công cụ sau:
- Visual Studio Community 2022
- SQL Server Integration Services Project
1.1 Tải và cài đặt cong cu SQL Server Data Tools vao SQL Server:
Bước 1: Tải Visual Studio Community 2022 và tiến hành cài đặt trên máy theo chỉ dẫn của trình cài đặt Nếu như máy đã có sẵn Visual Studio Community 2022 thì ta có thé đến bước 2
Bước 2: Mở Visual Studio Installer và chọn vào chức năng Modify của phần mềm
Visual Studio Community 2022
Trang 17Visual Studio Installer
Installed Available
All installations are up to date
Visual Studio Build Tools 2019
16.11.35
The Visual Studio Build Tools allows you to build native and managed MSBuild-based applications without
requiring the Visual Studio IDE There are options to install the Visual C+ + compilers and libraries, MFC,
ATL, and C++/CLI support
Visual Studio Community 2022
AN
Powerful IDE, free for students, open-source contributors, and individuals
Hình 2.1 Quy trinh tai céng cu Server Data Tools (1)
Buc 3: Chon SQL Server Data Tools va cac cài đặt khác dưới mục Data storage
and processing trong danh sach workload
Trang 18Modifying — Visual Studio Community 2022 — 17.9.6
Workloads _ Individual components
SF] Movie development witn G++
Build cross-platform applications for iOS, Android or
Windows using C++
Language packs
Gaming (2)
(Dy_ Game development with Unity
“WF Create 2D and 3D games with Unity, a powerful cross-
platform development environment
Other Toolsets (5)
8 Data storage and processing
Connect develop, and test data solutions with SQL Server,
Azure Data Lake, or Hadoop
Visual Studio extension development
Create add-ons and extensions for Visual Studio, inchuding
w commands, code analyzers and too! window
Location
C:\Program Files\Microsoft Visual Studio\2022\Community
By continuing, you agree to the license for the Visual Studio edition you selected We also offer the ability to download other software with Visual Studio
2rd Party Notices or in its accompanying license By continuing, you also agree to those licenses
This software is licensed separately, as set out in the
Installation locations
q
Game development with C++
Use the full power of C++ to build professional games powered by DirectX, Unreal, of Cocos2¢
Data science and analytical applications Languages and tooling for creating data science applications, including Python and F4
Office/SharePoint development Create Office and SharePoint add-ins, SharePoint
lutions, and VSTO add-ins usis #, VB and JavaSc
Installation details
» Visual Studio core editor
» ASP.NET and web development
» NET desktop development
* Data storage and processing
> Optional
‘SOL Server Data Tools
Azure Data Lake and Stream Analytics Tools
man NET Framework 4.72 development tools GitHub Copilot
F# desktop language support
» Individual components
» Extensions
Remove out-of-support components
Total space required 08
Install while downloading ~
Hình 2.2 Quy trinh tai céng cu Server Data Tools (2)
1.2 Tai cong cu SSDT cho phién ban Visual Studio Community 2022
Bước 1: Mở Visual Studio Community 2022 va chon Continue without code
| Visual Studio 2022
Open recent
4 Yesterday
fq SSIS_Furniture Store 2.sin
D\ VHọc kỳ 2\Kho dữ liệu và OLAP - IS217.O21\P:
4 This month
Eq SSIS Furniture Store sin
Ds \Hoc kp 2\Kho dia liệu và OLAP - IS217.C
Open a project or solution
Open a local Visual Studio project or sin file
Navigate and edit code within any folder
Create a new project
Choose a project template with code scaffolding
to get starter
&
4 Open a local folder
ũ
Trang 19Extensions
Window Help
P Search © ® - s x
ĐỘ He tá View CC Project Debug Analyze Tools
> Installed Sort by: Relevance y Lintegratiof XE
4 Online Rs SQL Server Integration Services Projects | Download | , Q eg J Created By: $8 Microsoft
This project may be used for building high aks a ae Installs: 408170
AT = performance data integration and workflow soluti
Search Results 5 Microsoft Pricing Category: Free
b Controls Rating: * * * (51 Votes)
> Templates Npgsql PostgreSQL Integration More Information
Piano Allows you to connect to PostgreSQL from within Visual Studio via Report Extension to Microsoft
Server Explorer, create EF6 model from existing database, etc
> Updates
Q GLSL language integration (for VS2022) [Preview]
VSIX Project that provides GLSL language integration
Indudes syntax highlighting (file extensions: glsl, frag, vert, geom, c
b Roaming Extension Manager
-5 NVIDIA Nsight Integration (64-bit)
NVIDIA Nsight Developer Tools Integration for Visual Studio (64-bit)
Scheduled For Install:
None
KR SSIS Integration Toolkit for Microsoft SharePoint
Scheduled For Update:
Enables you to connect, read and write to/from Microsoft SharePoint
None
~ Scheduled For Uninstall:
123 45 > None Change your settings for Extensions
Hình 2.5 Quy trình tải công cụ SSDT3) Bước 4: Khi công cụ đã được tải về thì mở file exe công cụ vừa tải xuông và nhân Continue
Trang 20& VERSION 1.3.2
i SQL Server Integration Services Projects
Welcome Click "Next" to begin
By clicking the "Next" button, | acknowledge that | accept the
This product will transmit information about your installation experience, as well as other usage and
performance data, to Microsoft to help improve the product To learn more about data processing and privacy controls, and to turn off the collection of this information after installation, see the
[eae
Hình 2.6 Quy trinh tai cong cu SSDT(4) Bước 5: Tick chon vao 6 Visual Community 2022 va chon Install dé bat dau qua trinh cai dat
Trang 21| VERSION 1.3.2
Œ SQL Server Integration Services Projects
Install this product to the selected Visual Studio instance(s):
Visual Studio Community 2022
Hình 2.7 Quy trinh tai cong cu SSDT(5) Bước 6: Sau khi cài đặt xong thì sẽ nhận được thông báo:
Trang 22Hinh 2.8 Quy trình tải công cụ SSDT(6)
1.3 Chuẩn bị kho dữ liệu:
Bước 1: Mở SQL Server Management Studio 20 và kết nối tới server bằng tải khoản
user cua window (Windows Authentication)
Trang 23inh 2.9 Mo SOL Server Management Studio va két noi voi server
Bước 2: Trên thanh công cụ chọn New Query và khởi tạo một cơ sở dữ liệu có tên là FurnitureStoreDW, day chính là cơ sở đữ liệu nơi chứa các bang Dim va bang Fact củng với các dữ liệu của các bảng đó
Câu lệnh:
CREATE DATABASE FurnitureStoreDW
LBP 5OLQuery1.sal - DESKTOP-0GVS511.master (D£SKTOP-0GVS51INmsi (60))* - Microsoft SQL Server Management Studio Quick Launch (Ctri+Q 2 - 8 x
File Edit View Query Project Tools Window Help
@-©|t3- ¿+ % la | «duy JA @@fa@|X⁄0|2-xc-|m| -|#, -|mz~&ø-,
MỸ | master -Ìbbeee s v §$ f8|[R]|| £° 8 ##| Ø[E|d)| # % | z# s | wv
Object Explorer = LQuery1.sql - DE SS1fÑmsi (60 |
Connects ¥ rare CREATE DATABASE FurniturestoreDil
| Integration Services Catalogs
4 SQL Server Agent (Agent XPs disabled)
4110 X vant Drosfilee
Hinh 2.10 Tao kho dit liéu ding dé clita cac bang Dim va bang Fact
Trang 242 Thực hiện qua trinh SSIS
2.1 Tao moi project SSIS
Buc 1: Mo Visual Studio Community 2022 va chon Create a new project
| Visual Studio 2022
Open recent Get started
ne repository like GitHub
4 Yesterday
FFq SSIS Furniture Store 2.sin /1 F a Open a project or solution
lọc k lơ I †\SSIS_Furnllure_Store.› pen a local Visual Studio project ‹ ile
4 This month
fq SSIS _Furniture_Store.sin 03/31 Bể Open a local folder
doc ky i { t i viture_St Navigate and nd edit code within any folde ¢
2
r ming\Android\FinalProject iq Create a new project
Choose a project terry lẹ with o
4 Older ` plat ode scaffolding
Trang 25
Recent project templates All languages + Allplatforms + Mprojettypes -
BY integration Services Project Ey Console App
A project for creating a command-ne application thst con run on NET on Windows, Linux and macOS
BT SOL Server Database Project Query Language Œ Linưt macOS (Windows Comscle
Bi ASP.NET Core Web App (Model-View-Controller) c Blazor Web App
A project template for creating a Blazor web app that supports both server-side rendering and dient interactivity This
a Console App (NET Framework) ce template can be used for web apps with rich dynamic user interfaces (Uts)
a Liman macds: Windows Blazon oud Web
ES) ASP.NET Core Web API o Bl ASP.NET Core Web App (Razor Pages)
A project template for creating an ASP.NET Core application with exarnple ASP.NET Core Razor Pages content
Cf Linut mACOS WWndOMs Clmud «Service WWb
ST ASP.NET Core Web API
A project template for creating a RESTIul Web API using ASP.NET Core controllers or minimal APIs, with optional support for OpenAPt and authentication
€® LinunGC macOQSỒ Windows «= APL = Cloud Service «Web APL
Fo] ASP.NET Core Web API (native AT)
A project template for creating a RESTIul Web API using ASP.NET Core minimal APs published as native AOT
C# linuG = macOS = Windows AP Cloud «Service = Web WA ADL
oa Thu 'eetinq a ca: brary that targets NET NET Standar:
Hinh 2.12 Chon mau Integration Services Project Bước 3: Đặt tén cho project va nhan Create dé tién hanh tao project
| Configure your new project
Integration Services Project
[J Place solution and project in the same directory
Project wil be created in “D:\Dai hgc\N4m 3\Hoc ky 2\Kho dữ liệu và OLAP - IS217.O21\Project
\SSIS_FurnitureStore\SSIS_FurnitureStore\”
Hình 2.13 Đặt tên cho project và xác nhận tao project
Trang 262.2 TAO BANG DIM VA BANG FACT
2.2.1 Tạo kết nối đến Server
Trước khi tiến hành việc xử lý và tách dữ liệu ra các bảng khác nhau thì ta cần phải tạo kết nối đến với Server
Bước l: Trong vùng Connection Managers ta nhân chuột phải và chọn New OLE
DB Destination
ĐỘ File Ect View Git Project Build Debug Tết Analyze Tools Extensions Window Help © Search — SSIS FurnitureStore ® - s x
{9 - E Ø8 Develop > Default - J Stat ~ D BH aR
& Hadoop File System Task
Ð Hedoop Hive Tesk
3 Hadoop Pig Task S& script task
® Send Mail lask
[rt] @® Web Service Task
Hình 2.14 Tạo kết nỗi tới Server trong cura s6 Connection Managers (1)
Bước 2: Nhắn vào New để tạo một Data Connection mới
Trang 278 Configure OLE DB Connection Manager D x
To create a connection manager based on previously defined connection information, select a data connection, and then click OK To create a new connection manager, click New
Trang 28
O Attach a database file:
Browse
Test Connection | OK Cancel Help
Hinh 2.16 Tao kết nỗi tới Server trong cura s6 Connection Managers (3) Tao cac bang Dim va Fact
Trước khi có thể tao các bảng Dim và bảng Fact thì ta cần tải dữ liệu gốc từ file Excel vào Data Flow:
Bước I: Tạo một Data Flow mới băng cách kéo thành phần Data Flow Task từ bên cửa sô SSIS Toolbox vùng làm việc chính của project
Trang 29- 68 2- Develop ~ Default - DP start - D & H a Package.dtsx [Design]* ©
(GRRE wt 02 cw Parameters BB] Evert anders $e Package Explorer
S& Script task
Hinh 2.17 Tao Data Flow Task mot
Bước 2: Khi nhân đúp vao Data Flow Task vừa tạo thi IDE sé chuyén qua man hinh
Data Flow O day vì nhóm muôn tải dữ liệu file Excel vì vậy nhóm sẽ sử dụng thành phân
Excel Source cua SSIS Toolbox
38t CDC Source
180% DI
| By Flat File Source
& OLE DB Source
= J Raw File Source
Trang 30Configure the properties that enable the Data Flow task to obtain data from Excel provider
Excel connection manager:
Data access mode:
Table or view Name of the Excel sheet:
4È Select a connection manager from the list of connection managers
OK Cancel Help
Hinh 2.19 Hop thoai Editor cua Excel Source
Bước 4: Khi hộp thoại tạo mới mở lên thì ta tiến hành chọn đường dẫn tới file Excel chứa dữ liệu gốc trong 6 Excel file path va chon phién ban trong Excel version va nhan OK
Trang 31Configure the properties that enable the Data Flow task to obtain data from Excel provider
Connection Manager | Specify a connection manager, data source, or data source view for the Excel source Then, select the
mode used to access data within the source After selecting the data access mode, select from among the additional data access options that appear
Excel connection settings
Specify an Excel file to connect to by selecting an existing file or by providing a file path to create a new B |
Excel file path:
C:\Users\msi\ Downloads\Super_Store_data.xlsx Browse
Hình 2.20 Tạo mới một Excel Connection
Bước 5: Chọn Excel sheet chứa dữ liệu
Trang 32Excel Source Editor D x
Configure the properties that enable the Data Flow task to obtain data from Excel provider
Connection Manager Specify a connection manager, data source, or data source view for the Excel source Then, select the Columns mode used to access data within the source After selecting the data access mode, select from among Error Output the additional data access options that appear
Excel connection manager:
Excel Connection Manager xị New
Data access mode:
Table or view v Name of the Excel sheet:
rksheet$
Preview
Hinh 2.21 Chon Excel Sheet
Bước 5: Nhân vào nút Preview đề xem lại các cột dữ liệu và dữ liệu có trong file Excel
Trang 33wij Preview Query Results 0 x
Query result (up to the first 200 rows):
odu Categ Sub-C Produ Sales Quantity Discount Profit
IR-B Furnit Bookc Bush 261.96 2 0 41.9136 |
IR- Furnit Tables Bretfo 957.5 5 0.45 -383 | IR-F Furnit Furnis Eldon 48.86 7 0 14.1694 IR- Furnit Tables Chro 1706 9 0.2 85.3092 IR- Furnit Chairs Globa 71.372 2 0.3 -1.0196
IR-B Furnit Bookc Rivers 3083.43 7 0.5 -1665
IR-F Furnit Furnis Electri 190.92 5 0.6 -147 JIR-B Furnit Bookc Atlant 532.3 3 0.32 -46.9 JR- Furnit Chais Globa 212.058 3 0.3 -15.147
JIR- Furnit Chairs Globa 89.99 1 0 17.0981 IR- Furnit Chairs Novi 319.41 5 0.1 7.098
ID_ Erirnit Cha¬iïirc Cinhs 912 445 E a3 -ic 9
Close |
Hình 2.22 Xem trước đữ liệu được tải lên
Bước 6: Chuyên qua tab Columns để chọn các cột đữ liệu mả chúng ta muốn sử dụng
để thực hiện trong suốt quá trình SSIS, đối với nhóm thì nhóm sẽ không sử dụng Postal
Code và Category nên sẽ bỏ chọn hai ô này Đồng thời, chúng ta sẽ đặt alias cho Sub- Category tr Sub-Category thanh Category
Trang 34OK Cancel Help
Hình 2.23 Chọn những cột đữ liệu cần sử dung cho quá trinh SSIS
* Luu y: Vi Output Column sé mac dinh lấy tên giống | voi External Column vi vay dé
tránh việc có khoảng cách trong tên của các cột dữ liệu sẽ khiến cho việc có truy xuất dữ liệu
SQL có thể lỗi nên nhóm đã quyết định sẽ xoá khoảng trắng trong tên của các cột đữ liệu Bước 7: Sau khi đã kiểm tra đã kiểm tra tất cả các thông tin thì nhân OK để hoàn tất quá trình tải dữ liệu vào Excel File Source
Bước 8: Tạo thành phần Data Conversion dé giúp chuyên đôi kiểu đữ liệu của các cột đữ liệu nhằm tránh những các lỗi về định dạng và giúp cho quá trình thao tác với các dữ liệu dễ dàng hơn cho các bước sau Sau khi tạo thành phần thì chúng ta sẽ kết nối Excel File Source với Data Conversion bằng cách kéo mũi tên Excel File Source nỗi với Data Conversion
Trang 35Configure the properties used to convert the data type of an input column to a different data type Depending on the data type
to which the column is converted, set the length, precision, scale, and code page of the column
OrderlD Copy of OrderlD ¬ Unicode string [DT WST 50
OrderDate Copy of OrderDate date [DT_DATE]
ShipDate Copy of ShipDate date [DT_DATE]
ShipMode Copy of ShipMode Unicode string [DT_WST 50
CustomerID Copy of Customer!D Unicode string [DT WST 50
CustomerName Copy of CustomerNa Unicode string [DT_WST 50
Segment Copy of Segment Unicode string [DT_WST 50
Country Copy of Country Unicode string [DT_WST 200
City Copy of City Unicode string [DT WST 200
State Copy of State Unicode string [DT_WST 200
Configure Error Output Cancel Help
Hinh 2.24 Chuyén kiéu đữ liệu của các cột bằng Data Conversion
Bước 9: Dùng công cụ Condifional Split và kết nối với Data Conversion để bắt đầu
cắt đữ liệu có điều kiện, lọc ra nhtmg dong NULL ra khỏi đữ liệu trước khi đưa dữ liệu vào kho di liệu Những dữ liệu không bị NULL thì ta sẽ đặt tên của Output Name là NotNull_Data
Trang 36
Ä9 - g BA © - & - develop -) Default > D stort ~ D BA
~®
Ñ„ canroi FInr KREOIENN €2 0zzmetrrs T7] Event Handlers FS Package Explorer °F
Data Flow Task: [gig Data Flow Task
BB ec —T Data Conversion TX concn so |
Hinh 2.25 Két noi Data Conversion t6i Conditional Split
ea
SSIS Toolbox ~qax
Search SSIS Toolbox 2
HY Balanced Data Distributor
& Conditional Split
4 Data Conversion 1] Data Streaming Destination
J Derived Column
® H0ES File Destination
® HDES File Source
Trang 37Specify the conditions used to direct input rows to specific outputs If an input row matches no condition, the row is directed to a default output
(4) Variables and Parameters (4 Ga Mathematical Functions
(4 Ga Columns (8 Sa String Functions
(4 Ga Date/Time Functions (8 Ga NULL Functions (4 Ga Type Casts (4 Ga Operators
Description:
Order Output Name Condition
1 | NotNull_Data 'ISNULL( [Copy of RowID] ) && !ISNULL( [Copy of Orde #
%
Default output name: NullData
Configure Error Output Cancel Help
Hình 2.26 Lọc ra những dòng dit liéu bj NULL
Bước 10: Tạo Multicast để có thể phân tân đữ liệu vừa được xử lý thành nhiều phiên ban dén cac bang Dimension va Fact Sau do, chung ta sẽ no1 Conditional Split dén voi Multicast đề kết nỗi
Trang 38ïm - )- Develop ~ Default ~ D Start» D _ tâ Package.dtsx [Design]* + X + ® | SSIS Toolbox ~ ax
@ Fi search SSIS Toolbox
or
Zo Control ow NT TU ge Parameters Ủ] Event Handlers “Y= Package Explorer
Data Flow Task: (ai
Re Input Output Selection x
The source or the destination component contains multiple inputs or outputs
Select an input and an output to connect the components
8 Output Input:
#Ï] Multicast Input 1
OK Cancel
S OData Source + ODBC Destination
& ODBC Source
FH OLE DB Command
FR Row Count
& Script Component
LZ Slowly Changing Dimension
$f Sort
Ý Union All
> Other Transforms
Hinh 2.27 Swe dung Multicast để phân tán đữ liệu 2.2.2 Bang Dim_Date
Buc 1: Tao moi thanh phan Sort cua SSIS Toolbox va đặt tên là Sort_Date dé lay ra cac cét dtr ligu can thiet cho Dim_Date Nhan dup Sort_Date dé mo hép thoai Edit Hai dit ligu ma ta can cho Dim_Date đó chính là OrderDate và ShipDate vì vậy ta sé chọn vào ô đầu tiên của hai dòng Copy of OrderDate và Copy of ShipDate(dữ liệu đã được
xử lý) theo thứ tự vừa nêu Sau đó, ta chọn Remove rows with duplicate sort values dé xoa các dòng đữ liệu trùng nhau Chọn OK để hoàn thành quá trình chọn
ĐỘ Hie Edt View Git Project Bulld DS 1+ sort Transformation Editor o x be ® - °
85 - cổ - rae Develt a
ø Ae Specify the columns to sort, and set their sort type and their sort order All nonselected columns are copied
unchanged Baa Control Flow GQMEEIEENM 9 Parameters (Event i @ @ search ssis Toolbox Dota Flow Task: [Ge Dai ' nh
B Nome Pass T "% Merge
Profit a *Y Merge Join
Copy of R a Ay Multicast
CopofO &
8 DưaGc — — 1 8Ì copy or s a [ eee
Copy of S a S0 LE DB Command Copy of C a [ BB Row Count
a S&F Script Component
—— _ \ L ly Changing Dimension
Input Column Output Alias Sort Type Sort Order Cor
Copy of OrderDate Copy of OrderDate ascending 1 IE]
Copy of ShipDate Copy of ShipDate ascending 2 Oar eee
recomm:
large
Output
@ Remove rows with duplicate sort values oK Cancel Help
Show output from:
Hình 2.28 Chọn dit liéu can thiét cho Dim_Date va xod dong tring Bước 2: Thêm thanh phan Derived Column và nhắn đúp để mở hộp thoại Edit
Trang 39Ez new columns ~ @ SSIS Toolbox 4x 3a ®@ Variables and Pararnaters @ FB Search SSIs Toolbox
Ở đây chúng ta sẽ chọn phương thức DATEPART(<kiễu dữ liệu thời gian>, cột dữ liệu) đê tiên hành tách các thuộc tinh can thiết của dữ liệu ngày tháng Ví dụ, nêu như ta muon lay thang cua Copy of OrderDate thi câu lệnh sẽ như sau:
DATEPART(“month”, [Copy Of OrderDate])
Trang 40
Specify the expressions used to create new column values, and indicate whether the values update existing columns or populate new columns
=] Discount | Gi Mathematical Functions
E] Profit 4) String Functions
#] Oopy of RowlD El Ea Date/Time Functions
#] Copy of OrdarID ¡#| DATEADD( «datepart», «number», «date» )
Z] Copy of OrderDate '&| DATEDIFF( «datepart», «startdate», «enddate» )
2l Copyof ShpDale
=] Copy of ShipMode kc] DAY( «date»
=) Copy of CustomerID &| GETDATE()
=) Copy of CustomerName |%| GETUTCDATE()
=] Copy of Segment í&| MONTH{( «date» )
=] Copy of Country I&| YEAH( «date» )
Derived Column Name Derived Column Expression Data Type
| OrderDate ị <add as new column> i DATEPART( "month", [Copy of OrderDate] ) four-byte signed inte |
Configure Error Output OK Cancel Help
Hình 2.30 Sử dụng hàm DATEPART đề tách các thành phần của đữ liệu ngày tháng
Bước 4: Tương tự với các cột OrderQuarter, OrderYear của cột Copy of
OrderDate và các cột ShipMonth, ShipQuarter, ShipYear của cột Copy of ShipDate
Tiép theo, nhan vao nut Configure Error Output