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))$$