日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

关系代数基本运算_关系代数的基本和附加运算

發布時間:2023/12/1 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关系代数基本运算_关系代数的基本和附加运算 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

關系代數基本運算

Definition

定義

Every DBMS must define a query language to enable users to access the data which is stored in the database. Relational Algebra is a procedural query language. It is used to query the database tables in order to access data in several ways. In this algebra, the input is a relation and output is also a relation. Operators are used to performing queries. It can be either unary or binary operator.

每個DBMS必須定義一種查詢語言,以使用戶能夠訪問存儲在數據庫中的數據。 關系代數是一種過程查詢語言。 它用于查詢數據庫表,以便以多種方式訪問??數據。 在這個代數中,輸入是一個關系,輸出也是一個關系。 運算符用于執行查詢。 它可以是一元或二進制運算符。

Basic Operations

基本操作

  • SELECT (unary)

    SELECT(一元)

  • PROJECT (unary)

    項目(一元)

  • UNION (binary)

    UNION(二進制)

  • SET DIFFERENCE (binary)

    設置差異(二進制)

  • CARTESIAN PRODUCT (binary)

    笛卡爾積(二進制)

  • RENAME (unary)

    重命名(一元)

Other Operations

其他作業

  • SET INTERSECTION

    設置相交

  • NATURAL JOIN

    自然加入

  • DIVISION

  • ASSIGNMENT

    分配

1)選擇運算(σ) (1) Select Operation (σ))

This is used to get rows (tuples) from the table (relation) which fulfill a given condition.

這用于從滿足給定條件的表(關系)中獲取行(元組)。

Syntax: σp(r)

語法: σp(r)

Where σ is used for the Select Predicate, r is the name of relation or table, and p is used as the propositional logic, where we give the conditions that must be fulfilled by the data. In this, unary and binary operators like =, etc., to mention the condition can be used.

其中σ用于Select謂詞,r是關系或表的名稱,而p用作命題邏輯,在此我們給出數據必須滿足的條件。 在這種情況下,可以使用一元和二進制運算符(例如=等)來提及條件。

Example: Student table and get data for students with age more than 20.

示例: Student表并獲取20歲以上學生的數據。

σage> 20 (Student)

年齡> 20(學生)

2)項目運營(∏) (2) Project Operation (∏))

Project operation is used to project or show only a desired set of attributes of a relation. In other words, if we wish to see only the names all of the students in the Student table, then the project operation can be used. It will only project the columns or attributes chosen and will delete duplicate data from the columns.

項目操作用于計劃或僅顯示關系的所需屬性集。 換句話說,如果我們希望僅在“學生”表中看到所有學生的姓名,則可以使用項目操作。 它只會投影選定的列或屬性,并且將從列中刪除重復的數據。

Syntax: ∏A1, A2...(r)

語法: ∏A1,A2 ...(r)

Here A1, A2 etc. are attribute names (name of columns).

在此,A1,A2等是屬性名稱(列名)。

Example:

例:

∏Name, Age(Student)

∏姓名,年齡(學生)

3)聯合行動(∪) (3) Union Operation (∪))

This is used to fetch data from two (relations)tables or temporary relations (the result of other operation).

這用于從兩個(關系)表或臨時關系(其他操作的結果)中獲取數據。

For union operation to work, the condition is that the relations(tables) taken should have an equal number of attributes(columns) and equal attribute domain. Even the duplicate tuples are automatically removed from the result.

為了使聯合操作起作用,條件是所采用的關系(表)應具有相等數量的屬性(列)和相等的屬性域。 即使重復的元組也會自動從結果中刪除。

Syntax: P ∪ Q

語法: P∪Q

Where P and Q are relations.

其中P和Q是關系。

Example: if we have two tables Regular class and Extra class, both have an attribute student to save the name of the student, then,

示例:如果我們有兩個表常規班級和額外班級,它們都具有屬性student來保存學生的姓名,那么,

∏Student(Regular class) ∪ ∏Student(Extra class)

∏學生(普通班)∪學生(普通班)

4)設置差異(-) (4) Set Difference (-))

This operation is used to find data which present in one relation but not present in the other relation. This operation can be applied to two relations, just like the Union operation.

此操作用于查找以一種關系存在但不以另一種關系存在的數據。 就像聯合操作一樣,此操作可以應用于兩個關系。

Syntax: P - Q

語法: P-Q

Where P and Q are relations.

其中P和Q是關系。

Example: if we want to find the name of students who take the regular class but miss the extra class, then, the below operation can be used as:

示例:如果我們想查找參加普通班但錯過額外班級的學生的姓名,則可以將以下操作用作:

∏Student(Regularclass) - ∏Student(Extraclass)

∏學生(普通班)-∏學生(額外班)

5)笛卡爾積(X) (5) Cartesian Product (X))

This operation is used to combine data of two separate relations into single and fetch data from the combined result relation.

此操作用于將兩個單獨關系的數據合并為單個數據,并從合并結果關系中獲取數據。

Syntax: A X B

語法: AXB

Example: to find the information for Regular Class and Extra Class which are conducted in the morning, then, the following operation can be used:

示例:要查找早晨進行的常規班和額外班的信息,則可以使用以下操作:

σtime = 'morning' (Regularclass X Extraclass)

σtime='早晨'(常規類X附加類)

6)重命名操作(ρ) (6) Rename Operation (ρ))

Rename operation is used to change the name or rename the output relation for any query operation which returns or gives the result like Select, Project etc. Or in simple words to rename a relation(table).

重命名操作用于為返回或給出諸如Select,Project等結果的任何查詢操作更改名稱或重命名輸出關系?;蛘哂煤唵蔚恼Z言重命名關系(表)。

Syntax: ρ(Relationnew, Relationold)

語法: ρ(Relationnew,Relationold)

翻譯自: https://www.includehelp.com/dbms/basic-and-additional-operations-of-relational-algebra.aspx

關系代數基本運算

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的关系代数基本运算_关系代数的基本和附加运算的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。