Relational Algebra / 关系代数符号可以用于表达数据库标准操作逻辑。近期做数据库作业时经常需要用 $\LaTeX$ 表示关系代数的符号,故在这里稍作整理。

Operation 中文 符号 $\LaTeX$
Projection 投影 $\Pi$ \Pi
Selection 选择 $\sigma$ \sigma
Renaming 重命名 $\rho$ \rho
Aggregate Function 聚合函数 $\mathcal{G}$ \mathcal{G}
Union $\cap$ \cap
Intersection $\cup$ \cup
Natural Join 自然连接 $\bowtie$ \bowtie
Left Outer Join 左外连接 … 这几个直接复制吧
Right Outer Join 右外连接
Full Outer Join 全外连接
Cartesian product 笛卡尔乘积 $\times$ \times
Divide $\div$ \div
Assignment 赋值 $\leftarrow$ \leftarrow
And 条件并列 $\land$ \land or \vee
Negation $\neg$ \neg
Exist 存在 $\exists$ \exists
For All 对所有 $\forall$ \forall
下标文字 $\sigma_{\text{username}}$ _{\text{}}
粗体文字 $\mathcal{G}_{\textbf{count(*)}}$ \textbf{}
长长长长括号 $\big( \Big( \bigg( \Bigg($ \big( \Big( \bigg( \Bigg(
比较 $\gt \ge \lt \le \ne$ \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\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))$$