Skip to content

Tables, keys and relationships · ⁨表、键与关系⁩

English

More than one table

Real databases split data across several tables. This lesson uses a small shop with two of them:

  • customer — one row per customer (id, name, city)
  • orders — one row per order (id, customer_id, order_date, total)

Storing the customer's name on every order would repeat it again and again. Keeping customers in their own table stores each one once.

中文

不止一张表

真实的数据库把数据分散在多张表里。本课用一个小商店,它有两张表:

  • customer —— 每位顾客一行(id、name、city)
  • orders —— 每张订单一行(id、customer_id、order_date、total)

如果把顾客的名字存在每一张订单上,就会一遍遍地重复。把顾客单独放一张表,每位顾客只存一次。

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩