<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Data Warehouse on Dat a Engineer</title><link>https://note.datengineer.dev/tags/data-warehouse/</link><description>Recent content in Data Warehouse on Dat a Engineer</description><image><title>Dat a Engineer</title><url>https://note.datengineer.dev/images/cover.png</url><link>https://note.datengineer.dev/images/cover.png</link></image><generator>Hugo -- 0.147.5</generator><language>en-us</language><lastBuildDate>Sun, 11 Aug 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://note.datengineer.dev/tags/data-warehouse/index.xml" rel="self" type="application/rss+xml"/><item><title>How to start a successful Data Warehouse project</title><link>https://note.datengineer.dev/posts/how-to-build-a-successful-data-warehouse-project/</link><pubDate>Sun, 11 Aug 2024 00:00:00 +0000</pubDate><guid>https://note.datengineer.dev/posts/how-to-build-a-successful-data-warehouse-project/</guid><description>In this article on the key factors for launching a successful Data Warehouse project, we will explore key considerations that can help ensure that your Data Warehouse achieves its intended goals and delivers value to the organization.</description><content:encoded><![CDATA[<p>Any organization aiming to leverage the power of data-driven decision-making stands to benefit greatly from a successful Data Warehouse project. A well-designed Data Warehouse not only centralizes your data but also guarantees that it is reliable, scalable, maintainable, and usable by stakeholders.</p>
<p>Over the past few months, my team and I have launched a new Data Warehouse project in production. The opportunity to start from scratch is always a valuable chance to gain new insights and expertise. I would like to share the experiences from this success story in the hope that they will be as beneficial to others as they have been to us.</p>
<h2 id="understand-business-requirements">Understand Business Requirements</h2>
<p>The first step in starting any project, not only a Data Warehouse, is to fully understand the business requirements. This is the difference between success and failure, not just a formality. If you skip this step, I can tell you with certainty that your project will be a waste of time, energy, and resources.</p>
<p>To really understand what business wants to see and what your team needs to do, it&rsquo;s essential to spend time talking to the people who will be using the Data Warehouse. What do they hope to accomplish? How will it help them do their jobs better? How do they plan to use the data? Getting a clear picture of their goals is essential to making sure your project is on the right track.</p>
<p><img alt="Importance of a clear requirements in Data Warehouse project success" loading="lazy" src="/posts/how-to-build-a-successful-data-warehouse-project/images/business-requirements.png"></p>
<p>However, this is where things often get complicated. People usually do not understand each other, especially people in different departments who have different perspectives, priorities, and terminologies. <strong>Sometimes people do not even understand what they are saying.</strong> Business guys are the ones who are easily attracted to marketing buzzwords on the Internet believing that these terms are the solutions to their problems. I have to say that the marketing departments of data companies do a really good job of re-inventing new names for the similar term. During this project, there were dozens of times the guys told me let&rsquo;s use this tool, why not use this technology, money is not a problem (until they actually got the bill).</p>
<p>In one of my previous projects, a stakeholder told me that he wanted a visually stunning real-time dashboard that would make the numbers dance instantly whenever users did something in the web application. And I had to explain to him:</p>
<ul>
<li>Visually stunning: Yes, the data analysts team can always help you with that.</li>
<li>Real-time: There is no real time. If the sun disappears, we can know it only after 8 minutes. So does the data.</li>
<li>We do not really need it. Business is not going to sit still and watch the numbers dance every second.</li>
</ul>
<p>Patience is the key. They do not understand those technical buzzwords. Yes. But isn&rsquo;t that why you are here as a technical specialist? Your responsibility is to listen to them, understand them, empathize with them, and tell them what you will do to help them. Your job is to translate their requirements into a workable solution.</p>
<p>Remember that the business stakeholders are not only the end users, but also the investors. Without their buy-in, the project can&rsquo;t even get off the ground. They are funding the project, and they deserve the best service.</p>
<p>By starting with a clear understanding of business requirements, you set the stage for a Data Warehouse project that is aligned with the organization&rsquo;s goals, ensuring that the final product delivers real value.</p>
<h2 id="understand-system">Understand System</h2>
<p>A Data Warehouse is not an isolated island. It is more like a bustling city that relies on a network of interconnected systems. It receives supplies from surrounding farms and industrial areas. Since Data Warehouse pulls data from other systems, you can not build a successful Data Warehouse without understanding how the other systems work.</p>
<p>Imagine stakeholders telling you they want the sales figure. Then you need to know exactly which systems hold the sales number. How is that number populated in each system? It may be manually entered by users, it may be automatically calculated, it may be synchronized from other sources, it may be read-only or editable&hellip; You need to know all the surrounding information to decide the source of truth for the number we desire. You may argue that all you need to do is copy the source database over and the business will know what to do with the data. Believe me, they don&rsquo;t. In fact, they have never seen the database a day in their lives. And you are the one who will tell them what they can do with your Data Warehouse.</p>
<p>And not knowing how the system works also risks your project design. You certainly don&rsquo;t want to discover a surprise when you&rsquo;re almost done with the implementation, such as a scheduled job that archives data from the database daily. If you had known that from the beginning, your design would have been very different.</p>
<p>Understanding the entire system in detail can be time-consuming. You should have a good sense of how the interconnected systems work together, but don&rsquo;t expect to understand them in detail at the beginning of your project. Instead, I would suggest building strong relationships with the teams responsible for maintaining these systems. Meet with them, tell them what you are doing, and ask for their advice and insights. They are a goldmine of information. You can also experiment with sandbox environments and databases to uncover hidden patterns and processes.</p>
<h2 id="design-a-reliable-data-warehouse">Design a reliable Data Warehouse</h2>
<p><a href="../what-is-a-reliable-data-system">Reliability is the backbone of any Data Warehouse</a>. If your business can&rsquo;t rely on the data coming out of your Data Warehouse, your project is completely a failure.</p>
<p>Having a solid testing strategy will greatly help. Testing is not just about finding bugs, it&rsquo;s about building confidence. When you start designing the data warehouse, think less about the time when the system is running happily, there is nothing for us to do if the system keeps running as it should. Think more about the time when the system is not working and what we are going to do in that time.</p>
<p><img alt="Bug is inevitable. The importance is how you deal with it." loading="lazy" src="/posts/how-to-build-a-successful-data-warehouse-project/images/there-will-be-no-bug-if-you-dont-write-any-code.png"></p>
<p>And even if you do your best, bugs and issues will still happen. Don&rsquo;t expect your system to be bug-free; instead, build processes to handle issues as soon as they arise. And most importantly, be transparent. If the business comes to you and asks about an issue they found, tell them what happened and what you are doing to help. Transparency is the key to trust. <strong>If you tell a lie, you are part of the problem; if you are transparent, you are part of the solution.</strong> A reliable Data Warehouse isn&rsquo;t just about technology. It&rsquo;s about building trust.</p>
<h2 id="choose-the-right-tool-for-the-right-job">Choose the right tool for the right job</h2>
<p>To build a Data Warehouse, you need a toolbox filled with different pieces to complete the picture: tools for copying data, transforming it, orchestrating jobs, and more. It is technically possible to create the tools yourself, especially if you are in a big corporation and want to control every aspect of the technology. However, in most of the cases, it is impractical. You do not have enough resources to own the technology. Thus, developing a Data Warehouse solution usually means picking the available tools and services and making them work together.</p>
<p>The real challenge is choosing the right tools. Beware of your enemies, the shiny marketing promises. The person who writes those buzzwords may not be the one who writes the code. Sometimes I don&rsquo;t understand what they wrote, and I think they don&rsquo;t understand what they wrote either. These tools are very expensive. It is important to avoid overkill. Focus on what your business really needs, not just what sounds cool. We are not going to use the most popular or the most expensive tools; we are going to find the right fit for our specific needs.</p>
<h2 id="start-small-grow-big">Start small, Grow big</h2>
<p>Your investors do not have infinite patience. They want to see progress and value. Building something small but functional is far better than promising a grand project that never finish. By starting small, you can quickly deliver value and gather feedback from users.</p>
<p>With limited resources, we can not get everything done at once. It is important to prioritize. What matters most to your business? What will deliver the biggest impact to your customers? Concentrate on delivering those core features first. You can break the project into phases, which is a good practice. Each phase focuses on specific business requirements, data sources, or user groups. And you can gradually expand the capabilities of the Data Warehouse.</p>
<h2 id="engage-users">Engage users</h2>
<p>A Data Warehouse is not just a technical marvel. It is a tool for your business. To ensure it delivers maximum value, you need to involve your users from the very beginning.</p>
<p>Imagine building a house without consulting the people who will live in it. People can still live in it, but they never feel it is their home. By involving them early and often, you will gain valuable insight into their needs, expectations, and challenges.</p>
<p>How can you engage your users?</p>
<ul>
<li>Involve them in the planning phase: Understand their data needs, pain points, and desired outcomes.</li>
<li>Provide regular updates: Keep them informed about project progress and involve them in decision-making.</li>
<li>Offer training and support: Equip users with the skills to effectively use the Data Warehouse.</li>
<li>Gather feedback: Encourage users to share their thoughts and suggestions for improvement.</li>
</ul>
<p>Remember that if you can not engage your users, any slightly higher number in their reports will quickly become <strong>your</strong> problem. <strong>If you can engage them and make them feel like they are part of the project, then any issue will become everyone&rsquo;s problem.</strong></p>
<h2 id="conclusion">Conclusion</h2>
<p>Building a successful Data Warehouse is a challenging journey that requires careful planning, execution, and continuous improvement. It all starts with a deep understanding of the business requirements to ensure that every decision is aligned with the organization&rsquo;s goals. Start small, iterate often, and always keep the user at the center of your efforts. A successful Data Warehouse is a collaboration between the engineering team and the business. By working together, you can create a solution that truly delivers value.</p>
]]></content:encoded></item><item><title>Understand Row-Oriented vs Column-Oriented Storage</title><link>https://note.datengineer.dev/posts/understand-row-oriented-vs-column-oriented-storage/</link><pubDate>Fri, 05 Apr 2024 00:00:00 +0000</pubDate><guid>https://note.datengineer.dev/posts/understand-row-oriented-vs-column-oriented-storage/</guid><description>Explore the basics and benefits of column-oriented storage, and learn about its advantages over row-oriented databases in processing OLAP queries.</description><content:encoded><![CDATA[<p>The way we access and analyze data has changed a lot lately. Row-oriented storage, which has been the standard for data storage for a long time, is having trouble keeping up with the demands of modern data analysis. In this article, I will introduce you to column-oriented storage and how it can help analytical queries run faster.</p>
<h2 id="olap">OLAP</h2>
<p>In my previous post, we discussed the <a href="../oltp-olap-why-we-need-data-warehouse">differences between Online Analytical Processing (OLAP) and Online Transaction Processing (OLTP)</a>. As a reminder, OLAP which is the access pattern of analytical queries typically:</p>
<ul>
<li>Consume a large number of records</li>
<li>Focus on only a specific subset of columns from each record</li>
<li>Aggregate data to calculate statistics (e.g., averages, sums)</li>
</ul>
<h2 id="row-oriented-storage">Row-Oriented Storage</h2>
<p>Row-oriented storage, a type of storage engine optimized for OLTP, stores all values belonging to a single row near each other. The entire row is essentially stored as a sequence of bytes and is usually indexed for quick retrieval. When you provide a key, the database efficiently locates the physical location of the row on disk. It then goes to that address, loads the sequence of bytes into memory, and parses it to extract the specific values you need. Let&rsquo;s think of it like a csv file. A row is stored as a string of characters. If you want to access the 10th row, you have to scan the file for the 10th line break, read all the characters until you reach the next line break. Now you have to parse the result by separating it by commas to get the information you want.</p>
<p>While row-oriented storage is great for reading and writing individual records, it quickly becomes less suitable when faced with the demands of OLAP:</p>
<ul>
<li>Index, the data structure behind the ability of most row-oriented data storage to quickly locate the data, doesn&rsquo;t work with analytical queries. Because analytical queries are OLAP, they don&rsquo;t access data using a specific key or ID. Instead, they often use multiple conditions, such as date created within a year or product category is of some specific types. Any column in the table can be used in the <code>where</code> clause, and we can&rsquo;t just create a separate row-based index for each column.</li>
<li>Reading a single row in row-oriented storage requires loading the entire sequence of bytes from disk into memory. Thus, reading a huge number of rows with hundreds of columns (which is typical in OLAP) quickly becomes inefficient.</li>
</ul>
<h2 id="column-oriented-storage">Column-Oriented Storage</h2>
<p>Column-oriented storage is based on a simple idea: instead of storing all the values from one row together, just store all the values from each column together. Because the data is organized by column, a query only needs to access and process the columns that are relevant to its needs. This significantly reduces the amount of data that needs to be transferred and parsed, resulting in dramatic performance gains.</p>
<p>Let&rsquo;s look at the example below. A sales table stored in a row-oriented format looks like this.</p>
<table>
  <thead>
      <tr>
          <th>DATE</th>
          <th>PRODUCT_KEY</th>
          <th>CUSTOMER_KEY</th>
          <th>QUANTITY</th>
          <th>DISCOUNT</th>
          <th>PAYMENT_METHOD</th>
          <th>&hellip;</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>2023/12/28</td>
          <td>2</td>
          <td>13</td>
          <td>3</td>
          <td>0.00</td>
          <td>card</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>2024/01/11</td>
          <td>2</td>
          <td>49</td>
          <td>5</td>
          <td>0.00</td>
          <td>bank</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>2024/01/16</td>
          <td>8</td>
          <td>49</td>
          <td>101</td>
          <td>15.00</td>
          <td>card</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>2024/01/21</td>
          <td>6</td>
          <td>55</td>
          <td>5</td>
          <td>5.00</td>
          <td>card</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>2024/02/02</td>
          <td>5</td>
          <td>26</td>
          <td>2</td>
          <td>0.00</td>
          <td>bank</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
      </tr>
  </tbody>
</table>
<p>A column-oriented storage serializes all values in a column and store them together (as a sequence of bytes). For our example table, the data would be stored in this way:</p>
<table>
  <thead>
      <tr>
          <th>Column</th>
          <th>Row 1</th>
          <th>Row 2</th>
          <th>Row 3</th>
          <th>Row 4</th>
          <th>Row 5</th>
          <th>&hellip;</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>DATE</td>
          <td>2023/12/28</td>
          <td>2024/01/11</td>
          <td>2024/01/16</td>
          <td>2024/01/21</td>
          <td>2024/02/02</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>PRODUCT_KEY</td>
          <td>2</td>
          <td>2</td>
          <td>8</td>
          <td>6</td>
          <td>5</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>CUSTOMER_KEY</td>
          <td>13</td>
          <td>49</td>
          <td>49</td>
          <td>55</td>
          <td>26</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>QUANTITY</td>
          <td>3</td>
          <td>5</td>
          <td>101</td>
          <td>5</td>
          <td>2</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>DISCOUNT</td>
          <td>0.00</td>
          <td>0.00</td>
          <td>15.00</td>
          <td>5.00</td>
          <td>0.00</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>PAYMENT_METHOD</td>
          <td>card</td>
          <td>bank</td>
          <td>card</td>
          <td>card</td>
          <td>bank</td>
          <td>&hellip;</td>
      </tr>
      <tr>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
          <td>&hellip;</td>
      </tr>
  </tbody>
</table>
<h2 id="advantages-of-column-oriented-storage">Advantages of Column-Oriented Storage</h2>
<p>Reading data from column-oriented storage provides several key advantages over traditional row-oriented storage, especially for analytical workloads:</p>
<ul>
<li><strong>Column compression</strong>: Due to the denormalization nature in modern data warehouse, values in a column tend to be repeated. Many popular compression algorithms, such as LZW or run-length encoding, make use of the similarity of <strong>adjacent</strong> data to optimize data size. Look at the column <code>PAYMENT_METHOD</code> in our example. What if, instead of storing a full 4-byte string, we only needed 1 bit for it: 0 for <code>card</code> and 1 for <code>bank</code>? Now the whole column becomes one long bitmap where each row consumes only 1 bit on disk.</li>
<li><strong>Access time</strong>: Disk access is a real bottleneck. When working with data on disk, we always need to use a different set of data structures and algorithms to minimize access time (B-tree for example). By accessing only the data needed to process the query and using data compression strategy, we can scan more rows in a single read. This means fewer reads to scan an entire table with trillions of rows, and therefore less disk access time.</li>
<li><strong>Throughput</strong>: Fetching only the necessary columns and better data compression also lead to better throughput, or the amount of data processed in a given time. Throughput is extremely important when compute and storage are not in the same place and data must be transferred over the network.</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>Each database implementation can vary in its specific optimization. However, the fundamental principle - storing and processing data by column rather than by row - remains the same, leading to significant performance gains for analytical queries. Understanding how your database works behind the scenes is beneficial for you as an engineer. Knowing what your tool does also means knowing what you do.</p>
]]></content:encoded></item><item><title>OLTP &amp; OLAP - Why we need Data Warehouse</title><link>https://note.datengineer.dev/posts/oltp-olap-why-we-need-data-warehouse/</link><pubDate>Wed, 28 Feb 2024 00:00:00 +0000</pubDate><guid>https://note.datengineer.dev/posts/oltp-olap-why-we-need-data-warehouse/</guid><description>Understand the fundamental distinctions between OLTP and OLAP databases, and gain insights into the need of a separate database called Data Warehouse</description><content:encoded><![CDATA[<p>Today, I was advising a team on building their data warehouse solution. I realized that even 40 years after the term &ldquo;data warehouse&rdquo; was first introduced, there are still questions about why we need a data warehouse and why we don&rsquo;t get all of the data from application databases, especially by executives. I write this post to answer these questions by clarifying the terms OLTP and OLAP, which are frequently used in discussions about data warehouse database architecture. Then I will explain why OLTP databases are inefficient for OLAP queries and why you need a separate database known as a data warehouse.</p>
<h2 id="oltp">OLTP</h2>
<p>OLTP, or <strong>Online Transaction Processing</strong>, is a pattern by which we access and manipulate data in the database transaction-by-transaction. A transaction refers to a single unit of work, such as a money transfer, a book, a blog post, and so on. Typically, users often only interact with one or a few transactions at a time. Therefore, most of the time, applications look up a small number of records in databases by some keys. Application databases implement special indexing techniques such as B-tree or LSM-tree to handle OLTP efficiently. They can quickly access a particular transaction given its indexed key.</p>
<h2 id="olap">OLAP</h2>
<p>As businesses grow and accumulate data, they need to analyze it to gain valuable insights about their market and customers. Then they can make informed decisions and gain competitive advantage. When it comes to analytics, access patterns will be very different. Typically, analytic queries consume a large number of records, look for only a few specific columns of each record, and often aggregate data to calculate statistics (min, max, sum, average,&hellip;). This pattern of accessing data in the database is called <strong>Online Analytic Processing</strong> (OLAP).</p>
<h2 id="difference-between-oltp-and-olap">Difference between OLTP and OLAP</h2>
<p>From the above definitions, we can somehow distinguish OLTP vs OLAP. The following table shows the typical differences:</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th>OLTP</th>
          <th>OLAP</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Access</td>
          <td>Small number of records, using indexed keys</td>
          <td>Large amount of records, often aggregate</td>
      </tr>
      <tr>
          <td>Purpose</td>
          <td>Application transactional consistency and speed</td>
          <td>Complex queries and analysis</td>
      </tr>
      <tr>
          <td>Users</td>
          <td>Application end users</td>
          <td>Analysts and business users.</td>
      </tr>
      <tr>
          <td>Data volume</td>
          <td>Relatively small, frequently accessed</td>
          <td>Large datasets, accessed less frequently</td>
      </tr>
      <tr>
          <td>Data type</td>
          <td>Real-time, current data</td>
          <td>Historical, aggregated data</td>
      </tr>
  </tbody>
</table>
<p><em>* Differences between OLTP and OLAP</em></p>
<h2 id="problems-of-oltp-databases-with-olap-queries">Problems of OLTP Databases with OLAP queries</h2>
<p>When your business is still young, it is easy to run analysis directly on application databases. However, as the volume of data and the need for analysis grows along with the business, problems arise. Databases that were optimized for OLTP using indexing techniques such as LSM tree or B-tree now struggle to execute OLAP queries efficiently. As a result, running OLAP queries becomes costly and negatively impacts application performance, which is critical to business success.</p>
<p>As the business continues to grow, different business units tend to operate independently with their own goals, priorities, concerns, and IT budgets. Each business unit will maintain its own applications running on separate databases. Performing analysis when data is scattered in different locations is difficult. And analysts often end up exporting data from different places, putting it into a single Excel file, and VLOOKUP.</p>
<h2 id="data-warehouse">Data Warehouse</h2>
<p>In response to the challenges of running OLAP queries on traditional business databases, the concept of a data warehouse is emerging as a solution.</p>
<ul>
<li>Data Warehouse functions as a dedicated space for analytical purpose. It allows business to store massive amounts of historical and current data without impacting operational databases.</li>
<li>Data Warehouses are designed with a focus on analytical processing. Their storage engines use specialized techniques to speed up OLAP queries. We may explore these techniques in other posts.</li>
<li>Data warehouses serve as a centralized repository for data from various sources. Analysis is now easier because all of the necessary data is in a single place.</li>
</ul>
<p><img alt="OLTP Databases to OLAP Data Warehouse" loading="lazy" src="/posts/oltp-olap-why-we-need-data-warehouse/images/data-from-oltp-databases-to-olap-data-warehouse.png"></p>
<h2 id="conclusion">Conclusion</h2>
<p>In this post, we&rsquo;ve gone over the definitions and differences between OLTP and OLAP. We also looked into the role of the data warehouse in conducting business analysis. Understanding them should give you the confidence when you say to your boss, &ldquo;We need a data warehouse.&rdquo;</p>
]]></content:encoded></item></channel></rss>