Friday, June 9, 2023

The importance of joins in relational databases

 Relational databases play a crucial role in organizing and managing vast amounts of data efficiently. One of the key operations in relational databases is the join operation, which allows the integration of data from multiple tables based on common attributes. This paper highlights the significance of joins in relational databases.

Relational databases are widely used in various industries, including finance, healthcare, e-commerce, and more, due to their ability to store and manipulate structured data. Joins enable the retrieval of relevant information by combining data from multiple tables based on common columns.

We have spoken previously about the relational model where data is stored in tables; those tables are self-contained from the logical perspective; in other words, the student table contains information about the students, the grades table contains information about the grades, the calendar table contains information about the academic calendar and so on. But most of the time, you are going to need to collect information from multiple tables to be able to produce meaningful information, and that is where you leverage the join technique to traverse from table to table to get the information you need using the relationships among those tables.

There are many types of joins, and they will be discussed in detail further down the road,

  • Inner Join
  • Left Join
  • Right Join (outer join)
  • Full Join
  • Cross Join
  • Self-Join


Inner joins and right joins (also commonly known as outer joins) are the two most common types of joins; on an inner join, rows from the two tables in the join are included in the result only if their related  columns match, while outer join returns rows from one table in the join even if the other table does not contain a matching row.

Here we have six students, but only five grades; please notice that “Nathan Edwards,” with student id 6519659, has not had grades posted yet.

 

When we join both tables using the where clause, there has to be a match on both tables in order to be included in the result set. 
 


However, there are times when you want all records to be displayed, even if it is to create awareness that a professor. To display all of the students who exist on the table, including those who do not have a grade, use the Outer Join operator. This operator, a plus sign enclosed within parentheses (+), will be placed on the side of the join condition that is deficient in information – the right side or student_grade table. 




Conclusion Joins play a fundamental role in relational databases, enabling the integration and retrieval of data from multiple tables based on common attributes. The ability to combine data efficiently has significant implications for data analysis, decision-making, and business operations across diverse industries. Understanding the various types of joins, their benefits, and their challenges is crucial for database administrators, developers, and analysts to design and optimize join operations effectively. By leveraging join optimization techniques, organizations can harness the full potential of relational databases and derive valuable insights from their data.

Wednesday, July 21, 2021

Time Boxing

  


DISCLAIMER: I am not the author of this article, and unfortunately I don't know how it got into my inbox, but I use this technique, and agree with the statements below, I am sharing it with you as it could be useful for you as well. the only contribution that I will add is that I also categorize with colors my to-do tasks, green for those that are not important because have a flexible deadline, red for those that are very important, orange is for research time or learning time and purple for anything personal.

 "Sunmary

In a recent survey of 100 productivity hacks, timeboxing — migrating to-do lists into calendars — was ranked the most useful. Timeboxing can give you a much greater sense of control over your workday. You decide what to do and when to do it, block out all distractions for that timeboxed period, and get it done. The benefits of calendarized timeboxing are many, varied, and highly impactful. The practice improves how we feel (control), how much we achieve as individuals (personal productivity), and how much we achieve in the teams we work in (enhanced collaboration). This may be the single most important skill or practice you can possibly develop as a modern professional, as it buys you so much time to accomplish anything else. It’s also straightforwardly applied and at no cost. Box some time to implement a version of this that works for you. 

Five years ago I read Daniel Markovitz’s argument for migrating to-do lists into calendars. Since then, my productivity has at least doubled.

That momentous (at least for me) article describes five problems with the to-do list. First, they overwhelm us with too many choices. Second, we are naturally drawn to simpler tasks which are more easily accomplished. Third, we are rarely drawn to important-but-not-urgent tasks, like setting aside time for learning. Fourth, to-do lists on their own lack the essential context of what time you have available. Fifth, they lack a commitment device, to keep us honest.

This was enough for me. I converted from my religiously observed to-do list (daily work plan) to this calendar system, also known as timeboxing (a term borrowed from agile project management). All five of Markovitz’s criticisms of to-do lists have manifested for me. In a study we conducted of 100 productivity hacks, timeboxing was ranked as the most useful. And over the last few years, I have also discovered several additional benefits of timeboxing, which I would like to share.

First, timeboxing into a calendar enables the relative positioning of work. If you know that a promotional video has to go live on a Tuesday and that the production team needs 72 hours to work on your copy edits, then you know when to place the timebox. In fact, you know where to place the timebox: it’s visual, intuitive, obvious. Working hard and trying your best is sometimes not actually what’s required; the alternative — getting the right thing done at the right time — is a better outcome for all.

Second, the practice enables you to communicate and collaborate more effectively. If all of your critical work (and maybe just all of your work, period) is in your calendar, colleagues can see it. So not only are you more likely to plan your work to accommodate others’ schedules (the paragraph above), others are able to check that your work schedule works for them. Shared calendars (with attendant privacy options) are the norm in the corporate world now, with Microsoft and Google leading the way.

Third, it gives you a comprehensive record of what you’ve done. Maybe you get to the end of a blistering week and you’re not even sure what happened? It’s in your calendar. Or a performance review looms — what were the highs and lows of the last six months? It’s in your calendar. Or you’re keen to use an hour to plan the following week and need to know what’s on the horizon. It’s in your calendar. Just make sure you have your own personal (i.e. not exclusively employer-owned) version of this data, or someday it won’t be in your calendar.

Fourth, you will feel more in control. This is especially important because control (aka volition, autonomy, etc.) may be the biggest driver of happiness at work. Constant interruptions make us less happy and less productive. Timeboxing is the proper antidote to this. You decide what to do and when to do it, block out all distractions for that timeboxed period, and get it done. Repeat. Consistent control and demonstrable accomplishment is hugely satisfying, even addictive. This is not just about productivity (largely external), this is about intent (internal, visceral) and how we feel.

Fifth, you will be substantially more productive. Parkinson’s law flippantly states that work expands so as to fill the time available for its completion. Although it’s not really a law (it’s more of a wry observation), most of us would concede that there is some truth to it (especially as it pertains to meetings). A corollary of this observation in practice is that we often spend more time on a task than we should, influenced by the time that happens to be available (circumstantial) rather than how long the work should really take (objective). Disciplined timeboxing breaks us free of Parkinson’s law by imposing a sensible, finite time for a task and sticking to that. Although it’s hard to precisely quantify the benefits of any time management or productivity measures, this is clearly enormous. Just take a commonplace example: do you habitually take two hours (cumulatively, often drawn out over multiple sessions) to complete a task that really could have been done in a single, focused, time-boxed hour? If the answer is yes, then your personal productivity might be double what it is right now.

The benefits of calendarized timeboxing are many, varied, and highly impactful. The practice improves how we feel (control), how much we achieve as individuals (personal productivity), and how much we achieve in the teams we work in (enhanced collaboration). This may be the single most important skill or practice you can possibly develop as a modern professional, as it buys you so much time to accomplish anything else. It’s also straightforwardly applied and at no cost. Box some time to implement a version of this that works for you."

 

 



Monday, June 7, 2021

You are not doing the proper assessment.

 

   

I have been in leadership roles for at least 14 years now, and when I have a hiring need, I personally weigh my hiring decision 50% based on soft skills and 50% on hard skills. The reason is straightforward; technology is constantly changing. I have been in places where X technology was used 100% of the time, therefore very relevant for the job, and in a matter of a week, you are using a totally different technology. 


I look for candidates with the passion and desire to learn, candidates that can adapt to the constant technology changes, that are open to sharing their knowledge with the team, that are a cultural fit with the organization, candidates that are enthusiastic and excited about the work they do. 


So, if technology is constantly changing, why do we fixate on the technical skills as if that was the most critical element?. 


I give you an example; 20 years ago, I was working for an International Software Company leader on mobile communications, I was a Database Administrator, and I got asked to create a C program based on pseudo-code given to me by a brilliant R&D director that happened to be my boss’s boss (Let’s call him Bob); I was good at SQL and PL/SQL, I also had previous coding experience I gained while earning my bachelor degree (COBOL, Fortran, REX, Basic, etc.). However, I had no prior experience with C, so once I got the task, I told Bob that I could do it, but It may take a little time since I have no previous experience coding in C. 


I could see that Bob had more faith in me than what I had in myself at that time. In my mind, I was estimating two weeks to code the program as it was not trivial ( a database fail-over routine that used a heartbeat technique to check that the database was healthy and responding to calls in less than 5 seconds; otherwise, the program will shut down the ill database, start a different database, reconnect database sessions to the new database and start the heartbeat process on the new database).  


I have to admit that I was a bit intimidated by Bob approaching me with this request; Bob was a brilliant man that mostly kept to himself, he was very respected in the company, and previous to his request, I do not recall we interacting directly ever, but as part of group meetings. 


I was excited and worried at the same time, but once I started, I was able to complete the code in 3 days; just after three days, I went from not knowing C to code a relatively complex C program. Bob, was surprised as he was expecting it would take longer, he asked me to demo it to him, which I did, and he was happy with it. 


My point is that sometimes hiring managers are fixating on technical qualifications, to the point that it looks like a contest of who knows more about a specific technology, and if they know more than you, then you are not qualified, they often do not evaluate well the soft skills of the candidate, and ignore the potential benefit that the person can bring to the organization. 


Ask yourself, how long will it take for a person with X technology to transition to Y similar technology? I will be surprised if you tell me more than 2 or 3 weeks, however getting a person in the team with the wrong soft skills can significantly delay work, demoralize the group and create a management nightmare for you. 


One of my old mentors and friend always says, “It is not the technology; it is the people.”


Cheers!!

Monday, April 12, 2021

-- How to create an exit loop in C++ --

 This is another typical question from my students.

#include <iostream>
using namespace std;

int main()
{
    bool exit = false;  // Variable to be used to signal the exit.
    char question; // Variable holding the value to be entered from the keyboard
    int x = 1;
    while (exit == false)  // If the user indicated they want to exit skip the loop
       {
         cout<<"Hello World:" << x << endl ;
         cout << "Do you want to exit (Y/N): "; // Ask the question
         cin >> question;  // Collect the answer from the keyboard
         if (toupper(question) == 'Y') // Evaluate the answer and change the value of exit.
         exit = true;
         
       }
    return 0;

-- How to introduce a pause in your C++ program --

 I often get asked by my students how to introduce a pause on their C++ program, the problem is that depending of the IDE you are using, after your program executes is closes the command line window automatically, so here are my 2 favorite approaches.

 Windows Operating System


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    cout << "Please press any key to continue";
    system("pause");
    return 0;
}

If you are using either Linux / Unix unfortunately the pause command does not work, but you can use something like this


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    cout << "Please press any key to continue";
    cin.ignore();
    return 0;
}


 

Saturday, November 23, 2019

-- How to clean your screen when coding C++ in a Mac OSx --

While working with a Mac Xcode is the most popular compiler, the problem is that Xcode uses a pseudo-terminal to run your code and the use of system("clear") will use give you an error such as TERM environment variable not set.


 
There is really no easy way to bypass that issue in Xcode, you could try to have a loop that introduces 250 or so blank endlines (endl) and it could look like the screen was cleared and you are refreshing it, but it could get messy.

The other alternative is to run your program from the OSx Terminal, for this you first navigate to where your .cpp code is, in my case it is in my desktop under the Test/Test so I navigate there using the cd (change directory) command, then I proceed to compile the C++ program using the make command as below. It creates an executable main without the .cpp extension






Next, I proceed to run the program




And below is the result as expected. You should only see one of the cout and that is why the screen was cleared and the first cout is gone.