Authoranvyst

Database design: when in doubt – use meta tables

It’s becoming quiet intriguing when you work with the 3rd party closed-source projects. You can see how the project was maturing, and how things were changing on the fly.

Especially when you have to plug in some extra logic on top of it, and the code is obfuscated, so the only way how to find all ins and outs – check the database schema.

Certain systems force to develop evil workarounds to coupe with bad design practices, whether it’s code or database wise.

How it all started

In the beginning of the project, apparentyly, developers came out with one-storage solution for holding the prices of products and domains, which is quiet obvious, as we shouldn’t re-invent any mystical entities to differentiate the concept of the price.

As the time fly, the notion of domain pricing strategies changed, as well as the billing/recurring amounts were introduced. In order not to break the compatibility of the previous versions (migrations scripts, duh? major version notifications, duh?), they kept the design and grew the table horizontally.

pricing layout of db
pricing layout of db Pricing layout

How it all ended

The end result got completely irrelevant in the ‘naming’ of the table. For instance, on the screenshot, we have 11.00 USD for registering domain for 10 years. On the backend side in lands into ‘biennially’ field. Logic? Nah, who needs that?!

So, what happened here? Developers ran out of the fields to store the year count for the domain registration, they just stated: “Whatever is in the pricing table except testsetupfee, will represent years of domain registration”.

Personally, it’s a classical example of meta tables design. When you don’t know how you’d scale the db table horizontally, and what kind of fields it’ll include – go for key/value table design.

Get a set of meaningful (yeah!) option_key’s store the values. If you’re concerned with the performance on this matter – don’t bother, it’s just a prices table.

For each product/domain entity you might have 10-100 records, depends how sophisticated your pricing model would go, but don’t break the fields notation that badly!

Good example of meta tables – WordPress wp_options design, and good execution wrappers on top – solves it all. If you’re insisting on horizontal table scaling – not a problem at all!

Just think about what you’ll end up with by the end of the day, and migrate it from meta tables after all.

Mattermost – host your own Slack-looking chat


Mattermost – open-source Slack competitor, with self-hosted option.

Evolution of Software industry

https://twitter.com/garybernhardt/status/152455259543961600

Note: Unfortunately Gary removed this tweet from his account :/

Twitter as communication tool for botnets

ESET researchers discovered an Android backdoor Trojan controlled by tweets. Detected by ESET as Android/Twitoor, it’s the first malicious app using Twitter instead of a traditional command-and-control (C&C) server.

After launch, the Trojan hides its presence on the system and checks the defined Twitter account in regular intervals for commands. Based on received commands, it can either download malicious apps or change
the C&C Twitter account to another one.

“Using Twitter to control a botnet is an innovative step for an Android platform,” says Lukáš Štefanko, the ESET malware researcher who discovered the malicious app.

First appearance of twitter-controlled botnets though was discovered in 2009, as mentioned in the article.

Comparing Twitter to other social media like Facebook, blogs (WordPress, Tumblr), Twitter stands out as a massive communication protocol – everyone talks with everyone, the message format is defined, limited by size. Twitter’s been used as a communication tool in many occurrences, either helping people as “Twitter monitoring of decease outbreaks“, or organising massive manifestations in Taksim square, Turkey.

twitter_cover

No wonder, why we ended up seeing Twitter as botnet communication tool.

In those days, I posed the concept that Twitter should not be a company alone. It should be an open protocol much like HTTP or email protocols (IMAP/POP). There should be an adopted industry standard that Twitter, the company, should and could (and still can) champion and work through with the guidance of other industry members.

It’s been published in 2012. Four years later, we’re witnessing the results, and more interesting things to come. There have been rumours that Twitter isn’t profitable, but tools it developed will evolve in the community anyway. Ideas get their niche and evolve in new products.

Greate quote from Agile Software Craftmanship describing some of the short-cuts in programming languages. Classical example – function call versus arrow functions.

“…the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code.Because this ratio is so high, we want the reading of code to be easy even if it makes the writing harder.”

— Robert C. Martin
Clean Code: A Handbook of Agile Software Craftsmanship

Why arrow functions are still not everywhere in the code.

© 2018 Andy's Cave

Theme by Anders NorénUp ↑