Relational 数据库
一句话解释
relational 数据库存储数据 in 表 (行 and 列) 链接通过关系, and uses SQL 到查询它.
用大白话说
A relational database organizes data into tables. Each table has columns (the fields) and rows (the records). Tables are linked by relationships — typically a column in one table references the primary key of another table.
例如, a 用户 table might have columns id, name, email. An 顺序 table might have id, user_id, 总计. The user_id column in 顺序 is a foreign key pointing to 用户.id, creating a relationship between orders and users.
Relational databases enforce a strict schema — every row must conform to the defined columns and types. They excel at complex queries, joins across tables, and transactional integrity. Examples: PostgreSQL, MySQL, SQLite, SQL Server, Oracle.
示例
-- Two related tables
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
total NUMERIC(10,2)
); user_id 外键 in 顺序 创建关系 — 每个顺序 belongs 到用户.
常见混淆
容易混淆的对象: NoSQL
关键区别: Relational 数据库 use 表 and SQL 使用 strict Schema; NoSQL 数据库 use flexible documents or 键-值 pairs 不使用 fixed Schema.
相关术语
相关资源
相关课程
- Relational Model
学习如何 relational 数据库组织数据到 表.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。