If you can add the products and categories using the PS Admin page without an issue, my guess us that the when entering the data directly, you are not creating the links between the categories and the products correctly.
try backing up the categories table, then deleting say 200 categories at a time. this is just to see if removing some of the categories can get it working again.
if that starts working, the problem could be in one of the categories that where removed, try adding them back in slowly to see if the problem comes back and try to isolate the category that causes the database to fail.