have been working in word press for about 6 months and I am just curious. Why is the data for the post or page template stored in a different table then wp_posts? Why not just create an extra column called template? and then store "index.php", "single.php", "archive.php"?
Doing so would then allow you to version templates with the pages and advanced users can write quires that retrieve posts specific to a particular template with few sql statements?