5 rules, why we use Foreign Keys in our databases:
- Relationships establishment - we can create relations between tables, and even inner join relation within one table between two records
- Data Integrity - for example, you can create an order with client_id for client which does not exist in the database
- Data consistency and accuracy - when foreign key is defined, it restricts the values that can be inserted or updated in the referencing column
- Data querying - thanks to the foreign keys we can retrieve data from multiple tables faster and easier
- Data maintenance - it helps cascading updates and deletions, preventing locks mechanisms