Just as any modern PHP application Magento stores most of its information in the MySql database (except media and xml configurations). Thus when debugging Magento problems it is useful to know a few things:
1. All MySQL queries can be logged and examined. For this purpose open the file lib/Varien/Db/Adapter/Pdo/Mysql.php and change the value of the protected property $_debug to true. You can also change the value of $_logQueryTime which is especially handy when debugging slowdowns. Once you make this change all queries will be logged in the file var/debug/sql.txt
2. Magento has an useful tool for fixing frequent database problems. This tool requires a working magento installation which database is used as reference for fixing a corrupted one.
Please remember always to backup your Magento database before making any changes to it.
Posted in: Magento