Primary keys and foreign key relationships that are correctly defined help ensure that you can write optimal queries. One common result of incorrect relationships is having to add DISTINCT clauses to eliminate redundant data from result sets.
When primary and foreign keys are defined as constraints in the database schema, the server can use that information to create optimal execution plans.