数据库常用关系代数符号在 LaTeX 中的表示

2020-04-15 (Wed.)

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

Operation 中文 符号 LaTeX\LaTeX
Projection 投影 Π\Pi \Pi
Selection 选择 σ\sigma \sigma
Renaming 重命名 ρ\rho \rho
Aggregate Function 聚合函数 G\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
下标文字 σusername\sigma_{\text{username}} _{\text{}}
粗体文字 Gcount(*)\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Πcount(σpublisher=’McGraw-Hill’(_publisher,Gcount(*) as count(books)))c\leftarrow \Pi_{count}\Big(\sigma_{\text{publisher='McGraw-Hill'}}(\_{publisher,} \mathcal{G}_{\textbf{count(*) as count}}(books))\Big)

tname,G_count(*) as memcount(σpublisher=’McGraw-Hill’(memberborrowedbooks))t \leftarrow_{name,} \mathcal{G}\_{\textbf{count(*) as memcount}} (\sigma_{\text{publisher='McGraw-Hill'}}(member \bowtie borrowed\bowtie books))

Πname(σmemcount=c(t))\Pi_{name}(\sigma_{\text{memcount=c}}(t))

© 2019 - 2024Juntong Chen ||
Dark Mode
|| RSS