Through In-Q-Tel, the CIA invested in a LOT of companies who were aiming to solve the problems they had. Google was another very early investment by In-Q-Tel on behalf of the NSA because Google's stated goal -- to collect, organize, and make sense of all of the world's data -- overlaps with what the NSA's goal is (and it's possible that Google might come up with better ideas and tech for doing it than the NSA's brain…
Note the "problems they had" aren't necessarily "they needed a better database technology". Oracle's mission is to have all bits of data in the world processed or stored on an Oracle system (source: I worked for Oracle, this was the internal mission statement). Oracle collects: 1. Who is staying in which hotels and in which rooms 2. Who is eating at which restaurants and going to which entertainment facilities 3. Who…
If not, what are you saying?