Relational Algebra / 关系代数符号可以用于表达数据库标准操作逻辑。近期做数据库作业时经常需要用 LATEX 表示关系代数的符号,故在这里稍作整理。
| Operation |
中文 |
符号 |
LATEX |
| Projection |
投影 |
Π |
\Pi |
| Selection |
选择 |
σ |
\sigma |
| Renaming |
重命名 |
ρ |
\rho |
| Aggregate Function |
聚合函数 |
G |
\mathcal{G} |
| Union |
交 |
∩ |
\cap |
| Intersection |
补 |
∪ |
\cup |
| Natural Join |
自然连接 |
⋈ |
\bowtie |
| Left Outer Join |
左外连接 |
⟕ |
... 这几个直接复制吧 |
| Right Outer Join |
右外连接 |
⟖ |
|
| Full Outer Join |
全外连接 |
⟗ |
|
| Cartesian product |
笛卡尔乘积 |
× |
\times |
| Divide |
除 |
÷ |
\div |
| Assignment |
赋值 |
← |
\leftarrow |
| And |
条件并列 |
∧ |
\land or \vee |
| Negation |
非 |
¬ |
\neg |
| Exist |
存在 |
∃ |
\exists |
| For All |
对所有 |
∀ |
\forall |
|
下标文字 |
σusername |
_{\text{}} |
|
粗体文字 |
Gcount(*) |
\textbf{} |
|
长长长长括号 |
(((( |
\big( \Big( \bigg( \Bigg( |
|
比较 |
>≥<≤= |
\gt \ge \lt \le \ne |
一个栗子🌰:
c\leftarrow \Pi_{count}\Big(\sigma_{\text{publisher="McGraw-Hill"}}(_{publisher,} \mathcal{G}_{\textbf{count(*) as count}}(books))\Big) \\
t\leftarrow _{name,}\mathcal{G}_{\textbf{count(*) as memcount}}(\sigma_{\text{publisher="McGraw-Hill"}}(member \bowtie borrowed\bowtie books)) \\
\Pi_{name}(\sigma_{\text{memcount=c}}(t))
c←Πcount(σpublisher=’McGraw-Hill’(_publisher,Gcount(*) as count(books)))
t←name,G_count(*) as memcount(σpublisher=’McGraw-Hill’(member⋈borrowed⋈books))
Πname(σmemcount=c(t))