In this article I’ll go into two related operations or kinds of queries you can do to data, that are both to do with grouping things – aggregation and window functions. I’ll describe how they both work, how they’re similar but different, and give examples of when you might use them including how you might … Continue reading Aggregation and window functions for data
Category: Database
Solving computer problems with indirection
There's a pattern that crops up a lot in computing - indirection. It's sometimes a little bit disguised, but it's used to solve many kinds of problem. To introduce it I'll first use an example from outside computing, that I like for many reasons. Five freedoms for animal welfare It might be a bit odd … Continue reading Solving computer problems with indirection
Comparing and aligning data models
Sometimes you are trying to bring two worlds together - two bits of code, each with its own data model. The two worlds could be a computer system you work on and the system from a partner you're trying to integrate with. The data models can be the most prominent bits of this integration, but … Continue reading Comparing and aligning data models
Mini roundabouts and deadlock
This is the first in a small series of articles using roundabouts to explore some ideas in computer science: Mini roundabouts and deadlockMagic roundabouts and starvation In this article I’ll go into dependency, which can lead to deadlock. For this I’ll be using the mini roundabout as an illustration. In the next article I’ll use … Continue reading Mini roundabouts and deadlock
Recursion and iteration – an introduction to iteration
This is the first of a series of articles about recursion and iteration Introduction to iterationIntroduction to recursionMutual recursion and tail recursionBlurring the linesLoop unrolling Recursion and iteration are both techniques for doing some work (or similar work) repeatedly, so that you can solve a bigger problem. This could be things like summing all the … Continue reading Recursion and iteration – an introduction to iteration
The cost of flexibility
Flexibility in software design is often seen as a good thing, but it can come at a cost. This isn’t surprising, because software engineering is a kind of engineering, and engineering involves making trade-offs among several good things. For instance, there is no “best” car, just the best car for a given situation, with a … Continue reading The cost of flexibility
Complexity: Performance trends in code
Introduction If you hang around programmers for long enough, you might hear people use terms like complexity or Big O notation, or say that performance is of the order … such as of the order N squared. I hope that this article makes those terms a bit less confusing. The basic idea is seeing how … Continue reading Complexity: Performance trends in code
Unit testing database queries
In this post I will try to describe an approach to unit testing database queries. It happened to be inspired by some testing I was doing of some C# code, but you could apply the same ideas to other languages. Note that if you’re unit testing stored procedures then I recommend using something like tSQLt, … Continue reading Unit testing database queries
An introduction to Entity Framework
Introduction This is article isn’t a hands-on guide to getting started with Entity Framework (EF). Instead it aims to give you an understanding of what EF is, whether it’s for you, and if so, which of its options apply best to you. In the next article I will do the hands-on stuff, where I walk … Continue reading An introduction to Entity Framework
Named parameters with default values can help unit tests
Introduction I find myself using default values much more in unit tests than in production code. That is, I do it more often, and use more parameters with defaults per method. This isn't because default values are bad, but they are often particularly useful when setting data up for unit tests. It makes the tests … Continue reading Named parameters with default values can help unit tests