I'm currently writing a book for PragProg called Building Distributed Services with Go (though it mostly applies to other languages too) that's walks you through building a distributed database from scratch. You can sign up on this mailing list to know when it's available: https://travisjeffery.us4.list-manage.com/subscribe?u=1e3ff7...
Yeah---each chapter begins with background on the chapter's topic, some theory, covers how and where you'd use what's we're talking about in the chapter and then we use it to build a part of the project we're building throughout the book. For example, in the consensus chapter we talk about what problems it solves and how you can use it in your projects,and then we implement Raft in the service for leader election and replication.