Polynomial Time Queries over Inconsistent Databases with Functional Dependencies and Foreign Keys