Is your question about creating the tiles and storing them in the database? Or is it assuming you already have that, and wondering how best to display them?
If the latter, I recommend OpenSeadragon:
http://openseadragon.github.io/
You just need to write a custom tilesource to produce URLs for the tiles: