There are a number of textbooks on Database Implementation.I used one from 1999. You should probably read "Seven Databases in Seven Weeks" to learn about the different kinds of DBs. Basically, a DB is just some very large data structures with optimized access algorithms.
There are a number of open source DBs, reading the code will be a real challenge. You have to know what each module is implementing and the subtle features. You have to be a serious language expert in whatever programming language they used.