Primary Keys, Foreign Keys and Relationships

Primary Keys, Foreign Keys and Relationships

Relational databases earn their name from relationships — the links that connect a customer to their orders, or an invoice to its line items. Primary keys and foreign keys are the tools that make those links reliable.

Understanding them in outline helps you see why your data stays consistent and why duplicate or orphaned records are kept at bay.

Primary Keys

A primary key is a unique identifier for each row in a table — often a simple counter or a randomly generated ID. No two rows can share one, which guarantees you can always pinpoint a single, specific record.

Foreign Keys

A foreign key is a column in one table that points to the primary key of another. It is how an order knows which customer it belongs to, creating the relationship between the two tables.

Why This Protects Your Data

  1. The database can refuse to create an order for a customer who does not exist.
  2. It can prevent you deleting a customer who still has live orders, avoiding orphaned data.
  3. It keeps reports accurate because every link is real and enforced, not just assumed.

If you need a hand with any of this, your Progressive Robot delivery team is ready to help. Raise a ticket from the Support area of your client portal or speak to your account manager and we will guide you through the next steps.

Did you find this article useful?