Logo
Section 1 / 5

关系代数简介

了解关系代数是什么,以及它为何构成了数据库系统的基本基础。

检查点

关系代数简介

了解关系代数是什么,以及它为何构成了数据库系统的基本基础。

\sigma_{condition}(TableName)

\sigma_{Price > 100}(Products)

1-- Selects all columns for products where the price is greater than 100 2SELECT * 3FROM Products 4WHERE Price > 100;

\pi_{Column1, Column2, ...}{(TableName)}

\pi_{CustomerName, Email}{(Customers)}

1-- Selects only the name and email columns from the Customers table 2SELECT CustomerName, Email 3FROM Customers;

\sigma_{Stock > 100}{(Products)}

\pi_{ProductName, Price}(...)

\pi_{ProductName, Price}(\sigma_{Stock > 100}{(Products)})

1-- Selects the name and price for products with more than 100 items in stock 2SELECT ProductName, Price 3FROM Products 4WHERE Stock > 100;

\rho_{NewName}{(TableName)}

\rho_{NewColumn1 \leftarrow OldColumn1, ...}{(TableName)}

\rho_{Customers}{(Clients)}

\rho_{Item \leftarrow ProductName,, Cost \leftarrow Price}\bigl(\pi_{ProductName,, Price}(Products)\bigr)

1-- Selects product names and prices, renaming the columns in the output 2SELECT 3 ProductName AS Item, 4 Price AS Cost 5FROM Products;

Quiz

单选题

在关系代数中,Select (σ) 操作符的主要目的是什么?

1 / 6

SQL 基础

连接操作