Raul Junco Profile picture
Sep 6 2 tweets 3 min read Twitter logo Read on Twitter
I was ready for the interview!

I knew the company was heavy on SQL, so I spent 3 days refreshing Normalization concepts.

But the questions were about Denormalization.

In Normalization, you reduce data duplication. In Denormalization, you add data redundancy.

When do you need it?

- When you have reporting or analytical requirements where complex queries are common.

- In applications where data is read frequently, and updates or inserts are less frequent.

- Denormalization can be helpful for caching.

- In cases where you have hierarchical data.

How to denormalize?

1️⃣ Identify the Tables to Denormalize:

Focus on tables that are frequently queried for reporting or analytical purposes.

2️⃣ Choose the Columns to Denormalize:

These are often the ones used in joins or frequently aggregated. Sometimes, you should include related data to simplify queries.

3️⃣ Create New Tables or Add Columns:

You can create new tables to store the denormalized data or add new columns to existing tables.
These new columns will contain the redundant data.

4️⃣ Populate Denormalized Data:

Populate the denormalized tables or columns with data from the original normalized tables. This can be a one-time or ongoing data migration.

5️⃣ Maintain Data Consistency:

Keep that the denormalized data stays in sync with the original normalized data.

To update the denormalized data, you may need:

- Triggers
- Stored procedures
- Batch processes

6️⃣ Optimize Queries:

Rewrite your queries to take advantage of the denormalized structure.

Simplify complex joins and aggregations, making your queries faster and more efficient.

𝗣𝗿𝗼𝘀:

- Denormalization will improve the speed of data retrieval.

- It simplifies complex queries, making them easier to write and understand, which is good for reporting and analysis.

- Precompute and store aggregated data, such as sums or averages, to avoid extensive calculations.

𝗖𝗼𝗻𝘀:

- Adding redundancy can lead to data inconsistencies. You must carefully manage updates and inserts to maintain data integrity.

- Storing more data consumes more disk space.

Does your Database need Denormalization?


Image
Image
Image
Great question!

Views allow for dynamic denormalization.

You can define views that join multiple tables and present denormalized data without actually storing it redundantly.

If you need to prioritize query performance and can accept the trade-offs associated with data redundancy and synchronization, denormalizing with tables is a viable option.

On the other hand, if data integrity and reduced maintenance complexity are critical, views are a better choice for presenting denormalized data dynamically without storing it redundantly.

In many cases, a combination of both approaches is the winning formula.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Raul Junco

Raul Junco Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @RaulJuncoV

Aug 11
Finding the data we need is an age-old problem.

But without the right search algorithms, you might be lost in the jungle.

Here are 7 Search Algorithms you need to know!

1. Linear Search: This is the simplest searching algorithm.

Elements are searched one by one in a linear… https://t.co/9aaEbIxQdFtwitter.com/i/web/status/1…



Image
Image
Image
Image
Interpolation Search: https://t.co/RTYYolHbQEtwitter.com/i/web/status/1…
Image
Jump Search: https://t.co/PDi2CA3FAYtwitter.com/i/web/status/1…
Image
Read 5 tweets
Aug 7
Talking to a Junior developer, I was stunned at how confused he was about 3 primary concepts.

But also remembered nobody explained these concepts back in my college days.

I hope this helps some young engineers out there. Image
1. Hashing: this is a one-way process used for data integrity verification.

It converts input data (plaintext) into a fixed-length string (hash value) using a hash function.

Hashing helps ensure data hasn't been tampered with, but it's irreversible! Image
2. Encryption: this is the real deal when it comes to data security.

It transforms data into an unreadable format (ciphertext) using an algorithm and a secret key. The ciphertext can be decrypted back to the original data with the right key. Image
Read 7 tweets
Aug 5
Everybody who writes tests knows the hard part is getting started.

Here are 5 steps to help you start writing tests like a Real Software Developer.
Write Your First Test

Start small and simple! Pick an isolated function—it doesn’t have dependencies, that is.

Set your test framework, and run your first test.

If you can test all the isolated functions, you’ll be a thousand times better off than without any tests. Image
Understand the Testing Pyramid

The testing pyramid categorizes tests into three layers:

- Unit, focus on testing individual components in isolation

- Integration, verify the interactions between different components

- End-to-End, ensure the entire system functions correctly Image
Read 8 tweets
Jul 24
Technical interviews are hard.

5 Do's and Don'ts

Do: Ask questions; the requirements are never complete; clarify them.
Don't: Assume requirements.

Do: Justify your trade-offs. Explain why you left that line there.
Don't: Assume your interviewer understands your solution.

Do:… https://t.co/FrkLnGbukxtwitter.com/i/web/status/1…
Technical interviews are hard, 5 Do's and Don'ts
Every week I write about my experiences and challenges as Software Engineer.

Threads break down complex tech into simple terms.

Share if you liked it.
Deisbel added a really good point here. 👇
Read 4 tweets
Jul 13
Over the last 6 years, I learned something I’ll never forget:

Frameworks and languages come and go, but the fundamentals always stay with you.

Here are 5 ideas you need to master: Image
1. Problem Decomposition

Breaking down complex problems into manageable parts is the first step.

Techniques like Divide and Conquer have been used since the beginning.

This technique reduces complexity and makes problem-solving more approachable.
2. Algorithm Analysis

Understanding algorithms and their efficiency are essential. Knowing their time and space complexity lets you choose the most appropriate one for a problem.

Proficiency in algorithm analysis allows you to optimize code and create efficient solutions.
Read 10 tweets
Jul 7
Ten years ago, you only needed to know GoF patterns, and you could call yourself a good developer.

That's not true anymore. If you want to build Hight Quality software, you need architectural knowledge.

4 basic architecture to start.
N-Layered Architecture

This architecture organizes applications into horizontal layers, each responsible for specific tasks.

- Presentation
- Business logic
- Data access

These layers promote separation of concerns and modularity.
Hexagonal Architecture

Also known as Ports and Adapters, Hexagonal Architecture isolates the core application from external dependencies.

The core defines ports/interfaces, while adapters implement them.
Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(