Implemented foreign key constraints validation.