Database tutorials can put you to sleep. This one absolutely will not.
Dive into raw data from the Cassini mission - straight from JPL, in the search for possible alien life. Oh yeah - and learn about PostgreSQL.
You've found yourself in charge of a PostgreSQL database... 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? PostgreSQL can help, but there's a lot more to this game.
Starting an application is simple enough, whether you use migrations, a model-synchronizer or good old-fashioned hand-rolled SQL. A year from now, however, when your app has grown and you're trying to measure what's happened... the story can quickly change when data is overwhelming you and you need to make sense of what's been accumulating.
Learning how PostgreSQL works is just one aspect of working with 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, slice off some fingers, or help you be the superstar that you are.
That's the perspective of A Curious Moon - data is the truth, data is your friend, data is your business. The tools you use (namely PostgreSQL) are simply there to safeguard your treasure and help you understand what it's telling you.
But what does it mean to be "data-minded"? How do you even get started? These are good questions and ones I struggled with when outlining this book. I quickly realized that the only way you could truly understand the power and necessity of solid databsae design was to live the life of a new DBA... thrown into the fire like we all were at some point...
Meet 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.
Much more than a tutorial, this book has a narrative element to it a bit like The Martian, where you get to know Dee and the problems she faces as a new developer/DBA... and how she solves them.
The truth is in the data...
A Curious Moon: Exploring Cassini's Data with PostgreSQL
Follow along with Dee Yan, our fictional data science intern, as she assumes the job of interim database administrator at the fictional aerospace startup, Red:4. She’ll learn PostgreSQL like we all do: on the job and under pressure.
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.
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.
Working with the PostgreSQL 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.
importing data from massive csv files
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..
WEEDING OUT THE INEVITABLE 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.
TRIAGING AND SIZING UP WHAT THE DATA MEANS
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.
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.
verifying what we have using sql
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 finally 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 fun you've ever had at work.
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 investements in your career... just ask these people...
Compulsively readable. Recommended.
"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."
I am loving the book!
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.
One of the best technical books I've ever read.
"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!"
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...
A Great Cosmic Mystery
Turns out this little moon gets squeezed between Jupiter 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...
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 containes 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 and all, but it's the data behind this story that's the fun 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 something new.
Spend the weekend with Dee and the gang at Red:4, digging in to the planetary mystery of Enceladus.
Frequently Asked Questions
Is this a print or digital book?
It's digital and there are no plans to print it just yet... though maybe someday. You can download PDF, epub (iPad/iOS) or Kindle versions.
Do I get any and all updates?
Yes - as with all of our books you get all updates now and forever.
What if I have problems?
You're not alone - a few people have had general issues and have needed some help and for that we have a GitHub repo that's linked in the book where you can ask questions. You can also send me, Dee or M. Sullivan an email.
Is this for real? You must have made some of this up?
Not one bit - all of it (the data and the story) comes from NASA/JPL. I did make up the main character, Dee Yan, as an amalgam of good friends of mine but all of the data is 100% straight from Cassini.
How can I get the data to play along?
There are links in the book that direct you to a ZIP file you can download. It's full of amazing CSV data including the "Master Plan" mission data that outlines every command sent to Cassini.