Primary keys uniquely identify records in a table. Foreign keys link tables by providing a link to a related table. A compound key uses two or more attributes to uniquely identify records when no single attribute can be used as the primary key, such as in a table recording bike rentals where a member can rent multiple bikes and bikes can be rented by multiple members, so the compound key uses the member ID, bike ID, and rental date.