Sobes.tech
Junior — Middle

How are relationships between tables established in a relational database?

sobes.tech AI

Answer from AI

In relational databases, relationships between tables are established using keys:

  • Primary Key — a unique identifier for a record in a table.
  • Foreign Key — a field in one table that references the primary key of another table.

The relationship is established by defining a foreign key, which ensures data integrity and allows for joins between tables.

For example, the Orders table may contain a foreign key customer_id, which references the primary key id in the Customers table. This links an order to a specific customer.

How are relationships between tables established in a… - sobes.tech