← Module 05 · Database & SQL
MODULE 05 · DATABASE & SQL

Relationship

A relationship describes how records in one table are logically connected to records in another table.

01 · What is it?

A relationship describes how records in one table are logically connected to records in another table.

For example, one customer can be connected to many orders. The relationship lets software work with those records as connected parts of one business story.

Simple Definition: A relationship explains which records belong together across tables.

02 · Think of it like...

Think of a relationship like a label that connects a person to the things they own.

A customer record does not need to repeat every order detail. Each order keeps its own record, while a shared identifier shows which customer it belongs to.

Customers

id · 42

name · Mina

Orders

id · 9001

customer_id · 42

03 · What does it do?

A relationship helps a database:

Connect Records

Link related records across tables.

Reduce Duplication

Store shared facts once instead of repeating them.

Support Queries

Combine related data when an application needs it.

Protect Consistency

Keep links meaningful and valid.

04 · Where is it used?

Relationships appear wherever one piece of business data depends on another.

Commerce

Customers connect to orders.

Content

Authors connect to posts.

Education

Students connect to courses.

Support

Customers connect to tickets.

05 · Example

Tables

customers
id | name
42 | Mina

orders
id  | customer_id | total
9001| 42          | 49.00

Query the relationship

SELECT customers.name, orders.total
FROM customers
JOIN orders
  ON orders.customer_id = customers.id
WHERE orders.id = 9001;

The query follows the relationship to return Mina’s order total.

06 · How it connects

Table APrimary KeyForeign KeyRelationshipQuery Result

The relationship is the logical connection; keys and queries are common ways to represent and use it.

07 · Do Not Confuse

Relationship

The logical connection between related records.

Foreign Key

A column that stores a reference to a record in another table.

JOIN

A SQL operation that reads related rows together.

Relationship = the connection · Foreign key = a stored reference · JOIN = a query operation

08 · Topic Glossary

ENGLISH TERM中文SIMPLE ENGLISH中文小白理解
Relationship关系A logical connection between records in different tables.不同数据表中的记录之间存在的逻辑关联。
Table表A structure that stores related data in rows and columns.用行和列保存相关数据的结构。
Record记录One complete set of data about an item.描述一个对象的一条完整数据。
Primary Key主键A value that uniquely identifies a record.唯一标识一条记录的值。
Foreign Key外键A column that references a record in another table.指向另一张表中记录的字段。
JOIN连接查询A SQL operation that reads related rows together.把相关表中的数据放在一起查询的 SQL 操作。
One-to-Many一对多One record is connected to many records in another table.一条记录可以关联另一张表中的多条记录。

09 · What to Remember

A relationship explains how records in different tables belong together.

Keys store references, and SQL queries can use those references to read connected data.

A clear relationship keeps data organized without repeating every fact.

↑