Bài giảng Kho dữ liệu và khai phá dữ liệu - Chương 4: Phân tích trực tuyến OLAP - Nguyễn Hoàng Ân

4.1 Từ bảng dữ liệu đến khối dữ liệu KDL dựa trên mô hình dữ liệu đa chiều nhìn dữ liệu dưới hình thức của một khối dữ liệu Một khối dữ liệu như bán hàng, cho phép dữ liệu được mô hình và được nhìn trong nhiều chiều  Các bảng chiều (Dimension Tables) như item (item_name, brand, type), hoặc time(day, week, month, quarter, year)  Bảng sự kiện (Fact Table) chứa các độ đo (Measure) (như dollars_sold) và các khóa có liên kết đến mỗi bảng chiều Một khối dữ liệu dựa trên n-D được gọi là một cuboid cơ sở.

pdf30 trang | Chia sẻ: thanhle95 | Lượt xem: 792 | Lượt tải: 1download
Bạn đang xem trước 20 trang tài liệu Bài giảng Kho dữ liệu và khai phá dữ liệu - Chương 4: Phân tích trực tuyến OLAP - Nguyễn Hoàng Ân, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Kho dữ liệu và khai phá dữ liệu Chương 4: Phân tích trực tuyến OLAP Nguyễn Hoàng Ân 1 Nội dung Mô hình dữ liệu đa chiều MOLAP, ROLAP, HOLAP Thiết kế và xây dựng Cube Các thao tác trên hệ thống OLAP Nguyễn Hoàng Ân 3 4. Mô hình kho dữ liệu 4.1 Từ bảng dữ liệu đến khối dữ liệu 4.2 Mô hình luận lý của KDL 4.3 Ngôn ngữ truy vấn khai phá dữ liệu (DMQL) Nguyễn Hoàng Ân 4 4.1 Từ bảng dữ liệu đến khối dữ liệu KDL dựa trên mô hình dữ liệu đa chiều nhìn dữ liệu dưới hình thức của một khối dữ liệu Một khối dữ liệu như bán hàng, cho phép dữ liệu được mô hình và được nhìn trong nhiều chiều  Các bảng chiều (Dimension Tables) như item (item_name, brand, type), hoặc time(day, week, month, quarter, year)  Bảng sự kiện (Fact Table) chứa các độ đo (Measure) (như dollars_sold) và các khóa có liên kết đến mỗi bảng chiều Một khối dữ liệu dựa trên n-D được gọi là một cuboid cơ sở. Nguyễn Hoàng Ân 5 Cube: Một lưới các Cuboids all time item location supplier time,item time,location time,supplier item,location item,supplier location,supplier time,item,location time,item,supplier time,location,supplier item,location,supplier time, item, location, supplier 0-D(apex) cuboid 1-D cuboids 2-D cuboids 3-D cuboids 4-D(base) cuboid Nguyễn Hoàng Ân 6 4.2 Mô hình ý niệm của KDL Mô hình kho dữ liệu:  Lược đồ hình sao (Star schema): Một bảng sự kiện ở giữa kết nối đến một tập bảng chiều  Lược đồ hình bông tuyết (Snowflake schema): Tinh chế của lược đồ hình sao, trong đó một vài chiều có sự phân cấp được chuẩn hóa thành một tập các bảng chiều nhỏ hơn, có hình ảnh giống như bông tuyết  Chòm sao sự kiện (Fact constellations): Nhiều bảng sự kiện chia sẻ các bảng chiều. Còn được gọi là lược đồ thiên hà (galaxy schema) Nguyễn Hoàng Ân 7 Ví dụ của lược đồ hình sao  time_key day day_of_the_week month quarter year time location_key street city province_or_street country location Sales Fact Table time_key item_key branch_key location_key units_sold dollars_sold avg_sales Measures item_key item_name brand type supplier_type item branch_key branch_name branch_type branch Nguyễn Hoàng Ân 8 Ví dụ của lược đồ hình bông tuyết time_key day day_of_the_week month quarter year time location_key street city_key location Sales Fact Table time_key item_key branch_key location_key units_sold dollars_sold avg_sales Measures item_key item_name brand type supplier_key item branch_key branch_name branch_type branch supplier_key supplier_type supplier city_key city province_or_street country city Nguyễn Hoàng Ân 9 Ví dụ của chòm sao sự kiện time_key day day_of_the_week month quarter year time location_key street city province_or_street country location Sales Fact Table time_key item_key branch_key location_key units_sold dollars_sold avg_sales Measures item_key item_name brand type supplier_type item branch_key branch_name branch_type branch Shipping Fact Table time_key item_key shipper_key from_location to_location dollars_cost units_shipped shipper_key shipper_name location_key shipper_type shipper Nguyễn Hoàng Ân 10 Nguyễn Hoàng Ân 11 12 Figure 11-13: Components of a star schema Fact tables contain factual or quantitative data Dimension tables contain descriptions about the subjects of the business 1:N relationship between dimension tables and fact tables Excellent for ad-hoc queries, but bad for online transaction processing Dimension tables are denormalized to maximize performance Nguyễn Hoàng Ân 13 Figure 11-14: Star schema example Fact table provides statistics for sales broken down by product, period and store dimensions Nguyễn Hoàng Ân 14Nguyễn Hoàng Ân 4.3 Ngôn ngữ truy vấn khai phá dữ liệu: DMQL Data Mining Query Language: DMQL Định nghĩa khối (Bảng sự kiện)  define cube []: Định nghĩa chiều (Bảng chiều)  define dimension as () Special Case (Bảng chiều chia sẻ)  First time as “cube definition”  define dimension as in cube Nguyễn Hoàng Ân 15 Định nghĩa lược đồ hình sao trong DMQL define cube sales_star [time, item, branch, location]: dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars), units_sold = count(*) define dimension time as (time_key, day, day_of_week, month, quarter, year) define dimension item as (item_key, item_name, brand, type, supplier_type) define dimension branch as (branch_key, branch_name, branch_type) define dimension location as (location_key, street, city, province_or_state, country) Nguyễn Hoàng Ân 16 Định nghĩa lược đồ bông tuyết trong DMQL define cube sales_snowflake [time, item, branch, location]: dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars), units_sold = count(*) define dimension time as (time_key, day, day_of_week, month, quarter, year) define dimension item as (item_key, item_name, brand, type, supplier(supplier_key, supplier_type)) define dimension branch as (branch_key, branch_name, branch_type) define dimension location as (location_key, street, city(city_key, province_or_state, country)) Nguyễn Hoàng Ân 17 Định nghĩa lược đồ chòm sao sự kiện trong DMQL define cube sales [time, item, branch, location]: dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars), units_sold = count(*) define dimension time as (time_key, day, day_of_week, month, quarter, year) define dimension item as (item_key, item_name, brand, type, supplier_type) define dimension branch as (branch_key, branch_name, branch_type) define dimension location as (location_key, street, city, province_or_state, country) define cube shipping [time, item, shipper, from_location, to_location]: dollar_cost = sum(cost_in_dollars), unit_shipped = count(*) define dimension time as time in cube sales define dimension item as item in cube sales define dimension shipper as (shipper_key, shipper_name, location as location in cube sales, shipper_type) define dimension from_location as location in cube sales define dimension to_location as location in cube sales Nguyễn Hoàng Ân 18 define cube sales [time, item, branch, location]: dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars), units_sold = count(*) Nguyễn Hoàng Ân 19 Các loại giá trị đo Phân phối (distributive):  Ví dụ: count(), sum(), min(), max(). Đại số (algebraic):  Ví dụ: avg(), min_N(), standard_deviation(). Tổng thể (holistic):  Ví dụ: median(), mode(), rank(). Nguyễn Hoàng Ân 20 Data Warehouse and Business Intelligence 21 Sự phân cấp mức ý niệm: Chiều (location) all Europe North_America MexicoCanadaSpainGermany Vancouver M. WindL. Chan ... ...... ... ... ... all region office country TorontoFrankfurtcity Dữ liệu đa chiều Sales volume as a function of product, month, and region P ro d u c t Month Dimensions: Product, Location, Time Hierarchical summarization paths Defined by concept hierarchies Industry Region Year Category Country Quarter Product City Month Week Office Day Nguyễn Hoàng Ân 22 Dẫn xuất Nguyễn Hoàng Ân 23 Một khối dữ liệu mẫu Total annual sales of TV in U.S.A. Date C o u n tr ysum sum TV VCR PC 1Qtr 2Qtr 3Qtr 4Qtr U.S.A Canada Mexico sum Các Cuboids tương ứng đến Cube all product date country product,date product,country date, country product, date, country 0-D(apex) cuboid 1-D cuboids 2-D cuboids 3-D(base) cuboid Nguyễn Hoàng Ân 25 Các tác vụ OLAP điển hình Roll up (drill-up) Drill down (roll down) Slice và dice Pivot (rotate) Các tác vụ khác:  drill across  drill through Nguyễn Hoàng Ân 26 Data Warehouse and Business Intelligence 27 Slicing Nguyễn Hoàng Ân 28 Drill-down Nguyễn Hoàng Ân 29 visualization Nguyễn Hoàng Ân 30 Data Warehouse and Business Intelligence 31 Mô hình truy vấn mạng hình sao (Star-Net) Shipping Method AIR-EXPRESS TRUCK ORDER Customer Orders CONTRACTS Customer Product PRODUCT GROUP PRODUCT LINE PRODUCT ITEM SALES PERSON DISTRICT DIVISION OrganizationPromotion CITY COUNTRY REGION Location DAILYQTRLYANNUALY Time Each circle is called a footprint
Tài liệu liên quan