Bölüm 3. Veri Ambarları http://ceng.gazi.edu.tr/~ozdemir Konular Veri ambarı nedir? Çok boyutlu veri modeli Veri ambarı mimarisi Veri ambarcılığı 2/35 1
Veri Ambarları ve OLAP Teknolojisi Veri ambarları çok boyutlu ve karmaşık verileri özetleyen ve katagorize eden teknolojidir. Bu teknoloji veri madenciliğinde şu ana kadar gördüğümüz ödüğü ü veri temizleme, birleştirme ve çevirme işlemlerini kapsamaktadır. Veri tabanları çevrim içi analitik işlemenin (Online Analytical Processing - OLAP) değişik boyutlardaki ve karmaşıklıktaki veriler için kullanılabilmesine olanak tanır. 3/35 Veri ambarları Veri ambarı Bir veri ambarı yönetimsel karar vermeye yardımcı olacak verilerin konu odaklı, birleştirilmiş, zaman değişken ve sabit olarak toplanmasıdır (W. H. Inmon). Veri ambarcılığı Veri ambarı oluşturma ve kullanma işlemi 4/35 2
Veri ambarı Konu odaklı Müşteri, ürün, satış gibi ana konular için geliştirilirler Karar verici makamlar için verinin modellenmesine ve analizine odaklanır Günlük işlemler ya da alışveriş hareketliliği veri ambarlarının konusu değildir. Gereksiz verileri ayıklar ve odaklandığı konu çerçevesinde basit ve anlaşılabilir bilgiyi sunar 5/35 Veri ambarı Birleştirilmiş Farklı kaynakların bir araya getirilmesi ile oluşur relational databases, flat files, on-line transaction records Veri temizleme ve birleştirme teknikleri uygulanır. İsimlendirme, birimler, vb. Veriler veri ambarına alındıklarında gerekli çevrimler yapılır. Değişik veri kaynakları arasındaki tutarlılık sağlanır 6/35 3
Veri ambarı Zaman değişkenli Zaman değişkeni canlı veri tabanlarına göre daha uzundur Canlı veri tabanları: Güncel veriler bulunur (en çok geçmiş 1 yıl) Veri ambarları: Geçmiş hakkında bilgi verir (geçmiş 5-10 yıl) Veri ambarının odaklandığı konu zaman içerisinde değişebilir A data warehouse's focus on change over time is what is meant by the term time variant. 7/35 Veri ambarı Statik Canlı veritabanlarından alınan veri farklı bir fiziksel bir ortamda saklanır Veri ambarında veri güncellemesi olmaz Canlı veritabanlarındaki değişim veri ambarlarını etkilemez Sadece ilk veri yüklemesi ve veri erişimi işlemlerini kullanır 8/35 4
Veri Ambarı - Birleştirilmiş Veritabanları Karşılaştırılması Veritabanlarının birleştirilmesi OLTP (on-line transaction processing): Farklı veritabanları arasında bir arabulucu katman Sorgulama tabanlı, karmaşık ve kaynak açısından verimsiz Bir sorgulamayı her veritabanı için alt sorgulamalara ayır Sonucu birleştir Veri ambarı OLAP (on-line analytical processing): Veri daha sonra kullanılmak üzere birleştirilip veri ambarında saklanıyor Birleştir me Sorgulama Veri Ambarı Alt Sorgular Sorgulama Arayüz Sonuç Veri ambarı Sonuç Birleştirilmiş veri tabanları 9/35 OLTP vs. OLAP OLTP OLAP users clerk, IT professional knowledge worker function day to day operations decision support DB design application-oriented subject-oriented data current, up-to-date detailed, flat relational isolated usage repetitive ad-hoc historical, summarized, multidimensional integrated, consolidated access read/write lots of scans index/hash on prim. key unit of work short, simple transaction complex query # records accessed tens millions #users thousands hundreds DB size 100MB-GB 100GB-TB metric transaction throughput query throughput, response 5
Çok boyutlu veri modeli Çoklu boyutlu veri modelinin temel birimi fact table lardır A fact table is a table that contains the measures of interest. For example, sales amount would be such a measure. This measure is stored in the fact table with the appropriate granularity. For example, it can be sales amount by store by day. In this case, the fact table would contain three columns: A date column, a store column, and a sales amount column. 11/35 Çok boyutlu veri modeli Lookup Table: The lookup table provides the detailed information about the attributes. For example, the lookup table for the Quarter attribute t would include a list of all of the quarters available in the data warehouse. Each row (each quarter) may have several fields, one for the unique ID that identifies the quarter, and one or more additional fields that specifies how that particular quarter is represented on a report (for example, first quarter of 2001 may be represented as "Q1 2001" or "2001 Q1"). 12/35 6
Star schema Çok boyutlu veri modeli star schema (veri küpü) lardan oluşturulur In the star schema design, a single object (the fact table) sits in the middle and is connected to other surrounding objects (dimension lookup tables) like a star. Each dimension is represented as a single table. The primary key in each dimension table is related to a foreign key in the fact table. 13/35 Star schema Assume a data warehouse that keeps store sales data Dimensions are time, store, product, and customer. The lines between two tables indicate that there is a primary key / foreign key relationship between the two tables. Note that t different dimensions are not related to one another. 14/35 7
Örnek 15/35 Snowflake schema The snowflake schema is an extension of the star schema, where each point of the star explodes into more points. In a star schema, each dimension i is represented by a single dimensional table In a snowflake schema, that dimensional table is normalized into multiple lookup tables, each representing a level in the dimensional hierarchy. 16/35 8
Snowflake schema The Time Dimension that consists of 2 different hierarchies: 1. Year Month Day 2. Week Day There are 4 lookup tables in a snowflake schema. A lookup table for year, a lookup table for month, a lookup table for week, and a lookup table for day. Year is connected to Month, which is then connected to Day. Week is only connected to Day. 17/35 Örnek Snowflake Schema 18/35 9
Snowflake schema The main advantage of the snowflake schema is the improvement in query performance due to minimized disk storage requirements and joining smaller lookup tables. Sometimes the performance may be negavitely affected due to increased number of join operations The main disadvantage of the snowflake schema is the additional maintenance efforts needed due to the increase number of lookup tables. 19/35 Çok boyutlu veri modeli Star schema veri küpü olarak da bilinir Veri ambarları veriyi star schema/veri küpü olarak gören çok boyutlu veri modelini kullanır. Bir veri küpü, örneğin satış, veriyi bir çok boyutta modellememizi ve görmemizi sağlar. Ürün veya zaman gibi boyut tabloları Veri ambarcılığı literatüründe, n-d boyutlu küp base cuboid (baz küboid) olarak adlandırılır. En yüksek seviyeden özet veriyi gösteren 0-D boyutlu küp apex cuboid (tepe küboid) olarak adlandırılır. Tüm küboidlerin oluşturduğu örgüde veri küpü olarak adlandırılır. 20/35 10
Veri küpü all time item location supplier 0-D(apex) cuboid 1-D cuboids time,item time,location item,location location,supplier time,supplier item,supplier 2-D cuboids time,item,location time,item,supplier time,location,supplier time, item, location, supplier item,location,supplier 3-D cuboids 4-D(base) cuboid 21/35 Çok boyutlu veri Ürün ay ve bölgenin bir fonksiyonu olarak satış verisi Dimensions: Product, Location, Time Hierarchical summarization paths Industry Region Year Category Country Quarter Produ uct Product City Month Week Office Day Month 22/35 11
Veri Küpü Oluşturma-Örnek SMARKET in satış verilerini tutmak için bir veri ambarı oluşturmak Başlama noktası zaman-reyon boyutlarında satış miktarı (TL) verisini i i tutan t 2-boyutlu tablo Şube: Çankaya Reyon Zaman Manav Şarküteri Fırın İlkbahar 1000 850 350 Yaz 1352 940 298 Sonbahar 1450 658 314 Kış 1500 965 365 23/35 Veri Küpü Oluşturma-Örnek SMARKET yöneticisini zaman-ürün boyutlarına birde şube boyutunu ekleyerek sonuçları görmek istiyor Sonuçlar çeşitli şubelerin değer tabloları bir araya getirilerek gösterilebilir. Şube: Çankaya Şube: Ulus Şube: Eryaman Reyon Reyon Reyon Zaman Manav Şarküteri Fırın Manav Şarküteri Fırın Manav Şarküteri Fırın İlkbahar 1000 850 350 2950 850 350 4155 850 350 Yaz 1352 940 298 6541 940 298 2140 940 298 Sonbahar 1450 658 314 1450 547 314 7520 658 654 Kış 1500 965 365 1500 965 365 1500 965 365 24/35 12
Veri Küpü Oluşturma-Örnek Değer tablolarının birleştirmesi ile elde edilen tablo çok açık değil/anlaşılması zor Farklı boyutlar için özet bilgi (toplam, ortalama, vs.) elde etmek mümkün değil Veri küpü şeklinde ifade edilebilir 25/35 Veri Küpü Oluşturma-Örnek Reyon Fırın Şarküteri Manav Toplam Zaman İlkbahar Yaz Sonbahar Kış Toplam Çankaya Ulus Eryaman Şube Toplam Hepsinin toplamı 26/60 13
Veri küpünü oluşturan küboidler Toplam Reyon Zaman Şube 0-D (apex) cuboid 1-D cuboids Reyon, Zaman Reyon, Şube Zaman, Şube 2-D cuboids Reyon, Zaman, Şube 3-D (base) cuboid 27/35 Veri Küpü Oluşturma-Örnek Bir başka boyut daha eklenseydi, 3B küplerin yan yana getirilmesi ile yada 4-boyutlu bir küp ile gösterilebilirdi. 28/35 14
Veri küpünde OLAP işlemleri Genelleme/Roll up (drill-up): Temelde veri özetleme işlemidir. 2 şekilde yapılabilir Oluşturulan hiyeraşi üzerinde yukarı doğru çıkılır (ay yıl) Boyut azaltımı yapılır. Derinleme/Drill down (roll down): roll-up işleminin tersidir. Oluşturulan hiyeraşi üzerinde aşağılara inilerek veri detaylandırılır Yeni boyutlar oluşturulabilir Slice and dice: project and select Veride istenilen bölge (dilim ya da küp) belirlenir ve kesilerek alınır Pivot (rotate): Veri küpü çevrilir, görsel olarak değiştirilir 3B veriden 2B veriler serisine çevrilebilir location (cities) Toronto 395 Vancouver time (quarters) Q1 Q2 605 computer home entertainment item (types) dice for (location = Toronto or Vancouver ) and (time = Q1 or Q2 ) and (item = home entertainment or computer ) location (countries) USA 2000 Canada time (quarters) roll-up on location (from cities to countries) Q1 1000 Q2 Q3 Q4 computer security home phone entertainment item (types) OLAP İşlemleri location (cities) item (types) Chicago New York Toronto Vancouver home entertainment computer phone security 605 825 14 400 computer security home phone entertainment item (types) Chicago pivot New York Toronto location (cities) 605 825 14 400 Vancouver Chicago 440 New York Toronto 395 1560 Vancouver Q1 605 825 14 400 Q2 Q3 Q4 slice computer security for time = Q1 home phone entertainment location (cities) ies) time (quarters) item (types) time (months) location (cities) drill-down on time (from quarters to months) Chicago New York Toronto Vancouver January 150 February 100 March 150 April May June July August September October November December computer security home phone entertainment item (types) 30/35 15
Data Warehouse Design Process Top-down, bottom-up approaches or a combination of both Top-down: Starts with overall design and planning (mature) Bottom-up: Starts with experiments and prototypes (rapid) From software engineering point of view Waterfall: structured and systematic analysis at each step before proceeding to the next Spiral: rapid generation of increasingly functional systems, short turn around time, quick turn around Typical data warehouse design process Choose a business process to model, e.g., orders, invoices, etc. Choose the grain (atomic level of data) of the business process Choose the dimensions that will apply to each fact table record Choose the measure that will populate each fact table record 31/35 Veri Ambarı Mimarisi Diğer Kaynaklar Metadata İzleme Birleştirme OLAP Server Veritabanları Veri çek İşle Yükle Yenile Veri ambarı Hizmet Veri madenciliği Veri Mart ları Veri kaynakları Veri depolama OLAP motoru Son kullanıcı 32/35 16
Three Data Warehouse Models Enterprise warehouse collects all of the information about subjects spanning the entire organization Data Mart a subset of corporate-wide data that is of value to a specific groups of users. Its scope is confined to specific, selected groups, such as marketing data mart Independent vs. dependent (directly from warehouse) data mart Virtual warehouse A set of views over operational databases Only some of the possible summary views may be materialized 33/35 Data Warehouse Development Distributed Data Marts Multi-Tier Data Warehouse Data Mart Data Mart Enterprise Data Warehouse Model refinement Model refinement Define a high-level corporate data model 34/35 17
Veri Ambarı Kullanımı Three kinds of data warehouse applications Information processing supports querying, basic statistical analysis, and reporting using crosstabs, tables, charts and graphs Analytical processing multidimensional analysis of data warehouse data supports basic OLAP operations, slice-dice, drilling, pivoting Data mining knowledge discovery from hidden patterns supports associations, constructing analytical models, performing classification and prediction, and presenting the mining results using visualization tools 35/35 Kaynak http://www.1keydata.com/ http://www.nytimes.com/2012/03/29/technology/new-usresearch-will-aim-at-flood-of-digital-data.html?_r=0 36/35 18