SQL databases:

NoSQL Databases:

PostgreSQL vs SQL server

Foreign key

Sure, here’s a simple example:

Let’s say we have two tables: Orders and Customers.

In the Customers table, we have:

CustomerID | Name     | Email           
-------------------------------------
1          | Alice    | alice@example.com
2          | Bob      | bob@example.com

And in the Orders table, we have:

OrderID | CustomerID | Product     | Quantity
--------------------------------------------
101     | 1          | Laptop      | 2
102     | 2          | Smartphone  | 1

In the Orders table, CustomerID is a foreign key that references the CustomerID column in the Customers table. This ensures that each order is associated with a valid customer. For example, order 101 is associated with customer 1 (Alice), and order 102 is associated with customer 2 (Bob).