On Single Source of Truth: Keeping it Clear and Simple…

Mary Rachael Koenke
6 min readOct 18, 2020

--

What is the truth?!?! Truth is hard to come by these days. With “fake news,” conspiracy theories, and rumors on Facebook and Twitter, contradicting yet all claiming to be true, deciphering what is truth is no easy task. The ethical implications of technology on truth on a macro level is controversial at best. Fortunately, if we focus our attention on a micro level, the source of truth is crystal clear. The source of truth is singular and essential. So what is it? What is the “Single Source of Truth (SSOT)?”

When I was first learning about SSOT, the concept was as confusing as trying to make sense of QAnon.

Wikipedia defines it in the following:

“In information systems design and theory, single source of truth (SSOT) is the practice of structuring information models and associated data schema such that every data element is mastered (or edited) in only one place. Any possible linkages to this data element (possibly in other areas of the relational schema or even in distant federated databases) are by reference only. Because all other locations of the data just refer back to the primary “source of truth” location, updates to the data element in the primary location propagate to the entire system without the possibility of a duplicate value somewhere being forgotten.”

Wait… what??

In simple terms, when implementing a SSOT while writing code, data should come from one place, and one place only. Anytime you retrieve data, no matter how many times it is retrieved, no matter where it is retrieved from, it should always be retrieved from the exact same place.

Let’s start by looking at the implications of a lack of SSOT so we can see how important it is. First, without a SSOT, code is inefficient and disorganized. If you are working with identical data that is stored in more than one place and have to update that data, then you are going to have to update the data in two, three, or a zillion places, which is a lot of work. (And programmers are lazy, but lazy in such a wonderful way!). Second, the previous reason illustrates a recipe for disaster by human error. The last thing we want to do in programming is to put all of our money on human accuracy. So let’s hedge our bets with Ruby.

Let’s imagine we have breaking news represented in an Article class. Article belongs to many Journalists and a Journalist has many Articles. On the other side of Article, it belongs to a Newspaper, and a Newspaper has many Articles.

Without a SSOT, the journalist would have to remember all of its articles, but the articles wouldn’t know who wrote them. The newspaper would have to remember all of the articles they published, but the articles wouldn’t know who published them. Even more importantly, the journalist would have no idea who was publishing their articles. Without a SSOT, this information would have to be updated individually in three different places every time someone wrote or published an article in order to maintain these relationships! Wayyyyy too much work!

Let’s define this model in Ruby code.

When defining the Article class, we can initialize the class with a journalist and newspaper. By doing this, we can connect the Journalists with Articles, Articles with Newspapers, and Journalists with Newspapers. An instance of the Article class is initialized with a newspaper and a journalist (and the title, of course!) and all the instances of Article is pushed into the All array, a class variable that will now hold all of the data for all of the Article instances. By doing this, we can store and access all of the information regarding the Journalist to Article to Newspaper relationship in one, single place!

Now let’s see how we can access this information outside of the Article class.

We can write simple instance methods in the Journalist class and Newspaper class that will iterate over the data stored in the Article class array to let the Journalist know which articles are theirs and the Newspaper know which articles are theirs! We can also write instance methods that will let the journalist know which newspapers published them and let newspaper know which journalist wrote for them! And every single time, the information is going to be accessed from the same SSOT, so the source of the actual data is in one, and only one place.

For the Journalist class we can add an articles method:

And for the Newspaper class we can add a similar articles method:

Adding these methods to their respective classes allows us to iterate over all of the articles and find all of the articles that belong to the Journalist and Newspaper, respectively.

We can add a newspapers method to the Journalist class and a journalists method to the Newspaper class so that the journalist can know which newspapers their articles are published in and the newspaper can know which journalists wrote the articles they published.

These methods iterate over the previous articles methods (articles belonging to the journalist, and articles belonging to the newspaper, respectively) and then give us the corresponding newspaper that published the journalist’s articles, and journalist that wrote the articles for the newspaper.

All of these relationships can be found from one single place, the data being stored in the Article class array because they were initialized with the corresponding journalist and newspaper. It’s our Single Source of Truth! Now we can update the information in one place, and only one place, and all of the places we accessed that information will know about it. My, oh my, that makes our lives so much easier!

Now if only we could apply this to news on a macro level… it would be goodbye to “fake news!”

Sources:

Wikipedia contributors. (2020, May 19). Single source of truth. In Wikipedia, The Free Encyclopedia. Retrieved 20:01, October 18, 2020, from https://en.wikipedia.org/w/index.php?title=Single_source_of_truth&oldid=957557400

--

--

Mary Rachael Koenke
Mary Rachael Koenke

No responses yet