<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aaron Mak on Medium]]></title>
        <description><![CDATA[Stories by Aaron Mak on Medium]]></description>
        <link>https://medium.com/@aaronmak?source=rss-651a72e6ed15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4T4PDkBnoUdxjzgd2OIO6g.jpeg</url>
            <title>Stories by Aaron Mak on Medium</title>
            <link>https://medium.com/@aaronmak?source=rss-651a72e6ed15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:21:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aaronmak/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Continuous Integration and Deployment for Data Pipelines at 90 Seconds]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@aaronmak/continuous-integration-and-deployment-for-data-pipelines-at-90-seconds-53bf10521ea7?source=rss-651a72e6ed15------2"><img src="https://cdn-images-1.medium.com/max/1988/1*Mi44U6YhEiWFOJOuwLpdAg.png" width="1988"></a></p><p class="medium-feed-snippet">Continuous integration and continuous deployment (CI/CD) is a practice that enables an organization to rapidly iterate on software changes&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@aaronmak/continuous-integration-and-deployment-for-data-pipelines-at-90-seconds-53bf10521ea7?source=rss-651a72e6ed15------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@aaronmak/continuous-integration-and-deployment-for-data-pipelines-at-90-seconds-53bf10521ea7?source=rss-651a72e6ed15------2</link>
            <guid isPermaLink="false">https://medium.com/p/53bf10521ea7</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Aaron Mak]]></dc:creator>
            <pubDate>Mon, 03 Dec 2018 09:39:09 GMT</pubDate>
            <atom:updated>2020-05-02T07:52:15.746Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to automate (most of) your grocery shopping for free with Trello and Zapier]]></title>
            <link>https://medium.com/@aaronmak/how-to-automate-most-of-your-grocery-shopping-for-free-with-trello-and-zapier-d426e6188ccf?source=rss-651a72e6ed15------2</link>
            <guid isPermaLink="false">https://medium.com/p/d426e6188ccf</guid>
            <category><![CDATA[trello]]></category>
            <category><![CDATA[grocery-shopping]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[zapier]]></category>
            <category><![CDATA[how-to]]></category>
            <dc:creator><![CDATA[Aaron Mak]]></dc:creator>
            <pubDate>Sat, 02 Jun 2018 11:58:58 GMT</pubDate>
            <atom:updated>2018-06-02T11:58:58.242Z</atom:updated>
            <content:encoded><![CDATA[<p>“Why are my credit card bills for grocery so high?”, my father said in a rather unpleasant tone. No one could give an answer. Since credit card bills don’t separate groceries by item and we don’t know who bought the item, no one knows who bought what. The root of this problem lies in transparency.</p><p>So how about creating a shared list? It would definitely solve the transparency issue since everything would be logged. But that creates another problem — it would take too much time if everything was done manually. Hmm, why not try to automate everything (for free)? After some trial and error, I’ve settled on a solution that worked for me and I hope it’ll work for you in some way too. You’ll need to do this on a computer so bookmark this and read it later if you’re on your phone.</p><h3>Create an account with these tools first</h3><h4><a href="http://trello.com/">Trello</a></h4><p>A flexible kanban list tool that can be used for almost anything.</p><h4><a href="http://zapier.com/">Zapier</a></h4><p>A service to connect various web applications with automated triggers and actions.</p><h4><a href="http://butlerfortrello.com/">Butler For Trello</a></h4><p>Kind of like Zapier with automated triggers and actions but only for Trello. And it allows you to create cool buttons as well.</p><p>Since I’m using free version of these tools, there are some limitations but it works for my use case.</p><h3>Using Trello as a grocery list</h3><p>A basic understanding of Trello is that a board contains multiple lists and each list contains multiple cards. It’s quite intuitive once you try it out yourself.</p><p>You would first need the basic lists — Instructions, To Buy, Bought, Rejected, Orders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CCtmldlzKUp-XVPPlGAcOA.png" /><figcaption>You should have something like this, without the “Bought Everything” button.</figcaption></figure><p>Don’t worry if you don’t have the Butler stuff yet. I’ll explain that later so just read on. Next, I added some basic instructions on how to use the Trello board. Feel free to be creative here but I generally prefer something simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QfV_V1wPdNLrzCXQmt3mgg.png" /><figcaption>Keeping it simple and clear.</figcaption></figure><p>At this point, we have easily solved the transparency problem. Every item that is bought can be seen clearly. Say I want to get a couple of items, I’ll add some cards to the “To Buy” list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NZ-1N4fWG0ayC7axyi7bQ.png" /><figcaption>Problem solved! Or not…</figcaption></figure><p>After purchasing the items, I’ll move the cards individually to the “Bought” list and add a new card to the “Orders” list. I hope you have realised the tediousness of this task. If I have a 20 different items, I’ll have to add a due date for each one and move them to the “Bought” list individually after purchasing them. And one more problem is that I don’t clearly know who added the item unless I traverse the activity feed.</p><p>But don’t worry, Butler to the rescue!</p><h3>Using Butler to automate Trello actions</h3><p>I’m not going to repeat what Butler has already said on their website regarding linking Butler with Trello so have a good read of <a href="https://butlerfortrello.com/powerup-help.html">https://butlerfortrello.com/powerup-help.html</a> first. In summary, you’ll need to add the Butler Power Up on your Trello board and authorise it as well. After that, you’ll need to go to <a href="https://butlerfortrello.com/dashboard.html">https://butlerfortrello.com/dashboard.html</a> and “Invite Butler”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6N1Jd4f6C9KgomoMoLjOA.png" /><figcaption>Before</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z7Qk-fNqpvRQK7pAOm7bAw.png" /><figcaption>After</figcaption></figure><p>After that is done, you can start with the fun stuff — automation. The following commands in monospace font can be added to the “Butler” list in multiple cards. You should end up with something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_30E2FvBYB0IWTkt4WxYzw.png" /><figcaption>The check/tick sticker appears when Butler understands your command.</figcaption></figure><pre>when a card is added to list &quot;To Buy&quot;, set due the next saturday at 9:00 am and add the green label to the card and add member @{username} to the card</pre><p>This helps everyone to see at a glance who added the card and since groceries are bought weekly on Saturday, the due date helps too.</p><pre>when a card is added to list “Rejected”, mark the due date as complete, and post comment “@{username} please justify this purchase” and remove all the labels from the card and add the yellow label to the card</pre><p>For any grocery item that is rejected.</p><pre>when a card is added to list &quot;Bought&quot;, mark the due date as complete</pre><p>To be used in conjunction with the “Bought Everything” button, which moves all items in the “To Buy” list to the “Bought” list.</p><pre>when a red &quot;Urgent&quot; label is added to a card by anyone, set due in 2 days and add member <a href="http://twitter.com/aaronmak">@aaronmak</a> to the card</pre><p>This gives me a notification that some grocery item is urgent, and I’ll try to purchase it before Saturday.</p><p>To add the board button “Bought Everything”, you’ll have to click the Butler button on the top right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7JjWXibOQ3MKDyklmq6BVQ.png" /></figure><p>You can either create your own command using the builder or copy and paste the following.</p><pre>archive all the cards in list &quot;Bought&quot;, and move all the cards in list &quot;To Buy&quot; to list &quot;Bought&quot;</pre><p>At this point, you would have automated everything except the “Orders” list, and the ordering groceries part of course.</p><h3>Adding orders as they come in</h3><p>I live in Singapore and we have quite a few online grocers to use. For this example, I’ll be using <a href="http://redmart.com/">RedMart</a>, partly because I prefer their user interface over the others. Depending on where you live, Amazon or any local one works as well. Once I place the order, an email will be sent by RedMart to me.</p><p>Before you can do anything, you’ll have to connect both your Gmail account (that RedMart sends emails to) and your Trello account with Zapier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42Y2veUivMZNk5G1ZqjuBg.png" /></figure><p>This step searches your email everytime a new one comes in. If it matches the search string, it will trigger the next action, which is to create a Trello card.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ErRYdYkupdXjgtSlw699Tw.png" /></figure><p>The Trello card that is created will follow a template that is defined by you. If I was using a paid version, I could do fancier stuff like add the date of order to the card name but just a text dump of the email into the Trello card description is sufficient.</p><p>Next, I’ll add one last command to the “Butler” list.</p><pre>when a card is added to list &quot;Orders&quot;, post comment &quot;bought on {date}, {time} <a href="http://twitter.com/board">@board</a>&quot;</pre><p>This tells me when I’ve ordered and informs everyone that an order has been made.</p><p>A small note here is that Butler Bot currently does not work on public boards, so private ones will have to do. Anyway, if it’s a grocery list, there’s no good reason for it to be public.</p><p>And there you have it, everything is automated for free except the buying of groceries which can be done in about 10 minutes 😎</p><p>The end result should look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*laU4fsKyWiJu-uoEhtYdzA.png" /><figcaption>If you have got here, good job!</figcaption></figure><p>It’s a pretty long tutorial but kudos for getting this far. So let me summarise the workflow.</p><ol><li>Anyone from the family adds groceries on “To Buy” list throughout the week.</li><li>Any item can be rejected by anyone throughout the week by moving the card to the “Rejected” list.</li><li>I would purchase the groceries every Saturday at 9AM.</li><li>After purchasing groceries, I would click the “Bought Everything” button. At the same time in the background, RedMart would send me an email to me detailing what I’ve ordered.</li><li>When Zapier detects I have received the order confirmation email, it would create a new card in the “Orders” list, detailing my order.</li></ol><p>For your reference, the public example Trello board can be found at <a href="https://trello.com/b/0a6YWIjL">https://trello.com/b/0a6YWIjL</a>. You won’t be able to see the “Bought Everything” button though because you are not a member of the board.</p><h3>Bonus: Fully automated grocery shopping</h3><p>If you would want a fully automated grocery shopping workflow, it wouldn’t come for free. You would need to hire a <a href="https://www.upwork.com/hire/virtual-assistants/">virtual assistant</a> to do what I’ve been doing manually. From my experience, it takes 10 minutes per week and I’d rather be the one choosing the groceries so I don’t think it’s worth it.</p><p>Last of all, just to show that it’s been working well in my family so far, check out our fully working Trello board 😊</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eQA8vT3tl_5OsZ5-cxl_Q.png" /></figure><p>Any improvements or suggestions are welcome! And I’d like to see what you’ve done with your grocery shopping workflow too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d426e6188ccf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tidying Datasets in Python]]></title>
            <link>https://medium.com/@aaronmak/tidying-datasets-in-python-8634f39159bc?source=rss-651a72e6ed15------2</link>
            <guid isPermaLink="false">https://medium.com/p/8634f39159bc</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[tidy-data]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <dc:creator><![CDATA[Aaron Mak]]></dc:creator>
            <pubDate>Mon, 02 Apr 2018 08:51:05 GMT</pubDate>
            <atom:updated>2018-04-02T09:20:42.280Z</atom:updated>
            <content:encoded><![CDATA[<p>Originally in R. Now in Python with Pandas.</p><h3>Why do we need tidy data?</h3><p>Raw data is messy. So how do we best clean it? <a href="https://www.jstatsoft.org/article/view/v059i10/">A paper published by Hadley Wickham</a> outlines a way to do it effectively and he coined the term <em>tidy data</em>. He pioneered libraries that were meant to work with tidy data to reduce the amount of time and effort needed for data cleaning.</p><p>In that paper, there were examples in R but I’d like to explore it using Python instead. Recently, similar libraries for data munging were created in python such as pandas. After all, Python is becoming the de-facto language for Data Analysts and Data Scientists.</p><h3>What is tidy data?</h3><p>Tidying data is a subset of data cleaning that we are looking at in this article. Wickham has developed some tools such as reshape , reshape2, and plyr to deal with this in R but lets see how we can deal with this problem in Python. I suspect that most of us have already been doing this but are not aware of it.</p><p>To learn how we can tidy data, we would need to understand what tidy data looks like.</p><blockquote>Tidy data is a standard way of mapping the meaning of a dataset to its structure.</blockquote><blockquote>In tidy data:</blockquote><blockquote>1. Each variable forms a column.<br>2. Each observation forms a row.<br>3. Each type of observational unit forms a table.</blockquote><h3>Tidying Data 101</h3><p>For example, let’s take a look at a simple dataset of some students and test scores.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6764879f7a84baeed047052b27c63b48/href">https://medium.com/media/6764879f7a84baeed047052b27c63b48/href</a></iframe><p>It might look like a nice dataset intuitively but it does not follow the rules of tidy data. Referencing the first rule where each variable forms a column, we have 3 variables — Student , Subject and Score. We broke this rule because each subject takes one column other than the first one. We have 4 observations per row, instead of 1 observation per row, breaking the second rule as well. However, we followed the last rule since we only have Score as an observational unit and it is in 1 table.</p><p>Using a simple melt transformation with pandas, we can convert this untidy data to something that follows our tidy data convention.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c43e43845d7e2d245a4269c8bbcbf9ef/href">https://medium.com/media/c43e43845d7e2d245a4269c8bbcbf9ef/href</a></iframe><p>The output would be a tidy dataset 🎉🎉🎉</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03b4460448eb8c50ab4b701cd13620fd/href">https://medium.com/media/03b4460448eb8c50ab4b701cd13620fd/href</a></iframe><p>Now you’ve got the hang of a simple example, let’s try tidying something a little more complicated.</p><h3>Tidying Data with Some Complications</h3><p>We never know in what form messy data might look like so this is just one of the possible examples you might come across. For this example, let’s take a look at the <a href="http://www.un.org/en/development/desa/population/migration/data/estimates2/data/UN_MigrantStockTotal_2015.xlsx">United Nations’ migration dataset</a> which shows us the movement of immigrants between various countries over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAEheYZGYYJHAARaFXn0Tg.png" /><figcaption>An excel sheet within the dataset</figcaption></figure><p>For this example, we will be looking at 2010 data alone, reducing our scope to just one time period. From the image above, we can see that the top few rows are (mostly) redundant so we can remove them for the purpose of this exercise. Thankfully, pandas has a handy method called read_excel which helps us do just that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/388c55521ca6c57e20e1939c906d94f9/href">https://medium.com/media/388c55521ca6c57e20e1939c906d94f9/href</a></iframe><p>Next, let’s rename some columns which have missing labels and drop some unused columns.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3f5ab9ef28f76419920f2414421ae77/href">https://medium.com/media/d3f5ab9ef28f76419920f2414421ae77/href</a></iframe><p>Last of all, let’s melt the dataframe.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef1d475438e33b16a5caab9a7f7e6eac/href">https://medium.com/media/ef1d475438e33b16a5caab9a7f7e6eac/href</a></iframe><p>And there you go, tidy data!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/189f754104d8074abe4de68ac62695d8/href">https://medium.com/media/189f754104d8074abe4de68ac62695d8/href</a></iframe><h3>My data is tidy, what’s next?</h3><p>We can use tidy data to explore our dataset. Say we’d like to find out the number of migrants that come to Singapore in 2010 for each origin country. A simple bar chart should do the trick.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab042b2b7bae80a65e21b7cc201c3714/href">https://medium.com/media/ab042b2b7bae80a65e21b7cc201c3714/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*G9wyYw0WJEDJQtE2x5uuLQ.png" /><figcaption>Easy peasy with tidy data.</figcaption></figure><p>Without much data wrangling, you are able to get a nice graph which shows that most migrants to Singapore in 2010 originate from Malaysia. This makes sense intuitively since Malaysia is just north of Singapore.</p><h3>That sounds boring… Give me the fun stuff</h3><p>A <a href="http://visit.crowdflower.com/rs/416-ZBE-142/images/CrowdFlower_DataScienceReport_2016.pdf">CrowdFlower survey</a> claims that <em>60% of time</em> is spent on data cleaning. That’s why being familiar with data cleaning tools are important. Get the basics right and you’ll have more time to spend on ‘fun stuff’ such as modelling.</p><p>I quite enjoyed playing around with the UN migrants dataset and there’s so much more you could try doing with it. From writing a simple loop to generate charts for each country to plotting the movement of migrants over time, the possibilities are endless. But first, let’s tidy some data. 😛</p><h4>References</h4><p><strong>Tidy Data by Hadley Wickham<br></strong><a href="https://www.jstatsoft.org/article/view/v059i10/">https://www.jstatsoft.org/article/view/v059i10/</a>.</p><p><strong>United Nations Migration Dataset<br></strong><a href="http://www.un.org/en/development/desa/population/migration/data/estimates2/estimates15.shtml">http://www.un.org/en/development/desa/population/migration/data/estimates2/estimates15.shtml</a></p><p><strong>Github Repo</strong><br><a href="https://github.com/aaronmak/tidy-data-python-example">https://github.com/aaronmak/tidy-data-python-example</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8634f39159bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand database tables like a boss]]></title>
            <link>https://medium.com/@aaronmak/understand-database-tables-like-a-boss-df86ca039b85?source=rss-651a72e6ed15------2</link>
            <guid isPermaLink="false">https://medium.com/p/df86ca039b85</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aaron Mak]]></dc:creator>
            <pubDate>Sat, 16 Dec 2017 01:19:52 GMT</pubDate>
            <atom:updated>2017-12-16T01:19:52.522Z</atom:updated>
            <content:encoded><![CDATA[<h4>Where’s my data dictionary?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JggJLMOPdaUrHEl0NM35HQ.jpeg" /><figcaption>The old school file system seems easier to understand sometimes.</figcaption></figure><p>There is so much advice out there about SQL but I feel that there isn’t enough about understanding the database we are querying from. If you’re like me, you would jump straight to using SQL to explore the data. Yet, over time, I’ve learned that it might not be the best way to start.The following are some simple rules that helped me better understand databases in a shorter period of time.</p><h3>Use a data dictionary (if given)</h3><p>If you are lucky, the database comes with a data dictionary. At the very least, it should give you a short description of the data with the respective column names and the datatype of each column. If not, please do not scream and shout, because we can try to figure that out.</p><h3>If no data dictionary is given 🙁</h3><h4>Column names</h4><p>Try to figure out if there is some sort of naming convention. If it contains count, num or cnt, it is likely referring to an integer count of an event or object like purchases_count. Similarly, a column name containing timestamp would suggest that that column contains a series of timestamps such as dropoff_timestamp.</p><p>Another obvious example might be a column name containing uuid or id which suggests the column contains the unique identifier of the object like employee_id.</p><h4>Description of the columns</h4><p>You must be thinking, what is this section for if nothing was given. If the column name is easy to understand and not something like foobar, write down a description of the column. This helps you to note down your assumptions about the column. After data exploration, your initial assumptions might wrong so revisit this description and change it if needed.</p><h4>Data type of the column</h4><p>This one is easy. But writing down the data type will help you in the long run. Especially when joining tables, you would want to be sure that the datatypes are the same for the joined columns.</p><p>The query below is for MySQL but any database would be able to do something similar by looking at their schema.</p><pre>SELECT column_name, data_type<br>FROM information_schema.columns <br>WHERE table_schema = &#39;&lt;DATABASE NAME&gt;&#39; <br>AND table_name = &#39;&lt;TABLE NAME&gt;&#39; <br>AND column_name = &#39;&lt;COLUMN NAME&gt;&#39;</pre><p>Good job! Now that you have a data dictionary, what now?</p><h3>Size of the data</h3><p>How many rows are there in each database table? Is it partitioned like in an <a href="http://www.aosabook.org/en/hdfs.html">HDFS</a>? A simple query like SELECT COUNT(*) FROM &#39;&lt;table name&gt;&#39; will tell you the number of rows. This is important especially when you are writing your own queries. Each query that you write uses resources. An unoptimized query for a large database could cost you much more than needed. Thread carefully when querying without filters and using a SELECT * statement.</p><h3>Range of the data</h3><p>A MAX(column_name) and MIN(column_name) can give you a good sense of the data. It’ll help you prevent unpleasant surprises such as only realizing much later that a column with integers only contais 1 and 0. For dates and timestamps, knowing the range might be helpful because it might give a hint about the ‘data freshness’ (see below).</p><h3>Primary &amp; foreign keys</h3><p>How is each row defined? Is there one product in each row? Usually, this can be determined by the primary key. For example, a table named customer with customer_id is likely to have one distinct customer in each row. Context is key. Not any column with an id is the primary key. A table named transaction with customer_id does not mean that customer_id is the primary key. Rather, customer_id in the transaction table is probably a foreign key. While some databases allow you to look at the schema for primary and foreign keys, remember, context is key. Figuring out primary keys and foreign keys will help you join tables easily in the future too.</p><h3>Data freshness — how frequently the data is updated</h3><p>The recency of the data usually depends on how critical it is to a business. If it needs to be up 24/7 like Amazon’s website, you can be sure that the database supporting transactions would be updated frequently. However, some databases that store aggregated data like customer spend or store revenue which is not critical to a business might only be updated once a day.</p><p>By ignoring the data freshness of the tables, when querying the ‘older’ data or joining them to other tables with ‘newer’ data, you might not get the expected result. For example, let’s say in a table which update transactions to the second, John had a transaction at 3pm today. In another table which contains customers’ details, it is only updated once a day at 12pm and one of the columns transaction_countcontains the count of all transactions per customer. Since the transaction was made before the customer details table was updated, it will not be reflected in the transaction_count column immediately and there will be a discrepancy until 12pm the next day. As such, it is important to keep the data freshness of each table in mind.</p><h3>Bonus: Draw an entity-relationship diagram</h3><p>It takes more than one post to teach about entity-relationship diagrams. But if you have the time and energy to learn how to draw one, I highly encourage you to do so. It’s like a mindmap for databases on steroids. You’ll learn to understand how to draw the relationships between tables and understand other entity-relationship diagrams at a glance. Check out <a href="https://www.lucidchart.com/pages/ER-diagram-symbols-and-meaning">https://www.lucidchart.com/pages/ER-diagram-symbols-and-meaning</a> for a good introduction and as most things, practice makes perfect!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*yTXuLMgCGnZ7V2vVrGO-sA.png" /><figcaption>It’ll look something like this.</figcaption></figure><h3>Bonus: Table creation logic</h3><p>If all else fails, there’s no better way to understand a table than to go to its creator. Existential questions about why a table was created can only be found in the source code. There might be helpful comments or hints of the ingredients needed to create the column.</p><p><em>Disclaimer: This might take the longest time since a table could be formed from many tables. As such, going through all of them might not be the wisest idea but you are sure to come out of it wiser.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df86ca039b85" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>