Junior — Middle
Kuidas luuakse seosed tabelite vahel relatsioonilises andmebaasis?
sobes.tech AI
Vastus AI-lt
Relational databases establish relationships between tables 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 joins (JOIN) 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.