The Foundation series covers this as well though I can't really recommend the book series. I tried a re-read when the TV show came out and felt pretty icky with how women were portrayed in the books. Also they aren't as good I remember. The TV completely diverges from the books but in a good way IMHO. Normally that bothers me a lot but after rereading the first book again I think I prefer the TV show.