Space. Rockets. Postgresql

Learn PostgreSQL the way the pros do: on the job and under pressure. You'll assume the role of interim DBA at aerospace startup Red:4, exploring data from the Cassini mission!

YOU'VE FOUND YOURSELF IN CHARGE OF A POSTGRESQL DATABASE FULL OF DATA FROM saturn... WHAT NOW?

Data is a powerful drug - it's the life blood of your business. How do you ensure that it's correct and tells the right story?

Starting an application is simple enough but a year from now, when your app has grown and you're trying to measure what's happened - that's when you're going to find out how well you took care of your data.

PostgreSQL is there to enable, enhance and extend what you do as a developer/DBA. And just like any tool in your toolbox, it can help you create crap or it can make you a superstar.


You'll step into the shoes of Dee Yan, our fictional intern at Red:4 Aerospace. She's just been handed the keys to a massive set of data, straight from Saturn, and she has to load it up, evaluate it and then analyze it for a critical project. She knows that PostgreSQL exists... but that's about it.

A CURIOUS MOON: EXPLORING CASSINI'S DATA WITH POSTGRESQL

You’ll start out with the basics: creating tables and importing data. Soon, however, you’ll be awash in glorious SQL and data from space (the NASA/JPL archives of the Cassini mission), creating functions, common table expressions and calculating aggregates using window functions all in the name of science while trying to figure out if there’s life under the ice of a very curious little moon.

Loren Stewart, Programmer

"A Treasure Trove..."

I’ve found the book to be a treasure trove of Postgres features. CTEs are blowing my mind right now. I’m a backend engineer, and I’ve been sharing what I’ve learned with my coworker who is a DBA. She is picking up some tips through me now! I haven’t found a good, engaging tutorial for these intermediate/advanced Postgres tricks, and "A Curious Moon" fills this gap. As a bonus, I’m also picking up some bash tips from the book.

YOU'LL DIG IN TO SOME OF THE MOST AMAZING DATA OF OUR LIFETIME...

I won't waste your time with sleep-inducing demos and examples - we're going to hit the ground running by importing millions of records into PostgreSQL right from the command line and then we're going to interrogate it for correctness. From there we put our detective hats on and get to work.

LEARN THE CLI

We don't have time for fluffy tooling! Yes there are GUIs and visual tools out there, but SQL with PostgreSQL is simple and easy to use when describing the precise table and index set that you want.

CSV Data Import

You'll import data like a pro, using the command line and a Makefile. There are GUIs you could use, but here at Red:4 we believe in keeping things simple and powerful.

Cleaning up crap data

You will become "data minded". You'll go through a basic audit process from real, raw data from JPL. It doesn't matter where the data is from, it will always have errors.

Data exploration

You'll sleuth through raw Cassini data using basic queries. Pulling data in is only part of the process – looking for clues and understanding what you're seeing is the next step. To do this you'll use Common Table Expressions, Full Text Search indexing and Windowing Functions.

Query optimization

You'll speed up slow queries with built-in analysis tools and objects. The Cassini data dump is gigantic, and sifting through the analysis records can be time consuming! You'll use EXPLAIN and ANALYZE to figure out where to put your indexes and when it makes sense to build a materialized view, which is data cached on disk.

data analysis

NASA is a very thorough organization, but it's staffed by humans and humans like spreadsheets and spreadsheets destroy data. You'll use mathematical analysis to verify flyby altitudes and speeds using data from the INMS during the 22 close encounters with Enceladus.

YOU'LL RUN QUERIES LOOKING FOR THE PRESENCE OF LIFE UNDER THIS AMAZING MOON

You'll perform the ultimate analysis on very real scientific data: Is There Life Under the Ice of Enceladus? You will have all the data you need to support this claim: thermal, chemical and mineralogical results from two of the most sensitive instruments humans have ever created. You'll run the query and see the results for yourself!

WORKING WITH DATA CAN BE THE MOST EXCITING JOB YOU'VE EVER HAD

It's a discovery that most DBAs don't want "app devs" to know: working with data is intoxicating. Learning the skills you need to effectively work with data can be one of the best investments in your career... just ask these people...

Reading through A Curious Moon... It's like reading The Martian, only instead of trying to survive in the hostile environment of another planet, it's about trying to survive in the hostile environment of snarky DBAs. Compulsively readable. Recommended.

Josh Tompkins

I am loving the book! The narrative format is like no other programming book I've ever read, and it's really keeping me engaged and interested. I've struggled in the past to keep pushing through programming books that are dry & stock standard, but the characters in A Curious Moon make the book relatable and it makes me want to learn.

Meggan Turner

I really am enjoying this book! It is one of the best technical books I've ever read, and I read more than 40 books per year (technical and non-technical). What I like most about this book is that you mixed a sci-fi story with technical writing. It is like a novel for geeks!

George Chatzimanolas

Highly recommend A Curious Moon to anyone looking to hone their SQL skills. The book has such an unique style. It’s like reading The Martian.

Rolando Murillo

WAIT ARE YOU SERIOUS? ENCELADUS? POSSIBLE LIFE UNDER ITS ICY SHELL?

Yes, absolutely. Back in 2005 Cassini did a routine flyby of Enceladus, a moon that's about the size of Great Britain (313 mi in diameter). It's the most reflective body in the solar system, covered with smooth ice... except for its south pole...

one heck of a  cosmic mystery

Turns out this little moon gets squeezed between Saturn and Titan and the gravitational pull grinds out some heat within its core. Heat that produces temperatures up 90 C in some spots, which look suspiciously like the deep water plumes we see here on Earth. Oh, but it gets weirder...

A bioreactor?

That heated water produces plumes at the moon's south pole which jet material into space. We didn't know what was in that material until 2007, when Cassini flew right through them at ridiculously high speeds and low elevation.

The onboard mass spectrometers scooped it up and... wouldn't ya know... it's sea water. There's a salty ocean under the ice and it contains methane and hydrocarbons that mirror the deep sea "chimneys" that we have here on Earth. This has led scientists to speculate that Enceladus is a bioreactor, capable of producing life in extraordinary circumstances.

This little moon is quite small, about the size of Texas, yet it jets water out continuously into space. Some of it rains back down as fine ice particles, covering the surface and making it the most reflective body in the solar system. Some of it gets sucked back into Saturn itself, making Enceladus the only moon we know of that contributes matter back to its host planet.

And some of it goes into orbit, creating the "E ring" of Saturn which you see above. That ghostly blue glow, the second largest planetary ring in the solar system, was created entirely from the icy jets of Enceladus... which is way too small to contribute that much material.

what the hell is going on up there!

I don't know... you tell me. We can speculate all day about aliens, sunken UFOs and Thor's hidden palace but you know what would be even better? Letting the data tell us what's going on.

That's what we do as data people: let the data tell us the story. It's all in there, and with Cassini's mission data we have a gigantic amount that we get to sift through for answers.

That you get to sift through. Buckle up! PostgreSQL is fun, but it's the data behind this story that's the exciting part. When you're done with this story, you'll be able to run (and understand) one hell of an amazing database query. These results were dubbed a "smoking gun for life in the waters of Enceladus" by NASA itself.

The most fun you'll have learning about data

Spend the weekend with Dee and the gang at Red:4, digging in to the planetary mystery of Enceladus. A casual, fun read for those who know and appreciate data and database, or an exciting tutorial for programmers wanting to learn more about PostgreSQL.