關系代數基本運算_關系代數的基本和附加運算

關系代數基本運算

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.

其中PQ是關系。

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.

其中PQ是關系。

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等結果的任何查詢操作更改名稱或重命名輸出關系。或者用簡單的語言重命名關系(表)。

Syntax: ρ(Relationnew, Relationold)

語法: ρ(Relationnew,Relationold)

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

關系代數基本運算

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/380145.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/380145.shtml
英文地址,請注明出處:http://en.pswp.cn/news/380145.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

遠控免殺專題 14 ---AVIator

0x01 免殺能力一覽表 幾點說明: 1、上表中標識 √ 說明相應殺毒軟件未檢測出病毒,也就是代表了Bypass。 2、為了更好的對比效果,大部分測試payload均使用msf的windows/meterperter/reverse_tcp模塊生成。 3、由于本機測試時只是安裝了360全…

面型對象 (包package)

面向對象(package關鍵字的概述及作用) 為什么要有包 將字節碼(.class)進行分類存放 包其實就是文件夾 代碼如下: package beyond.hjj;//在當前運行目錄下創建一個子目錄結構beyond\hjj,在子目錄下存放已經編譯成字節碼文件的clown.class類。 class c…

【Web開發】級聯查詢(Ajax/ jQuery/ Servlet)

實現級聯查詢 共有兩個下拉框&#xff0c;第一級為學院&#xff0c;第二級為學院開設的科目。 實現的功能為&#xff1a;當改變學院的選擇&#xff0c;第二級下拉框需變為對應學院開設的科目內容。 結果預覽&#xff1a; jsp頁面 <% page contentType"text/html;…

asp.net treeView綁定

這個東西不是什么復雜的東西&#xff0c; 幫著小兄弟寫個Demo, 實現個Binding public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Bind(); } } priv…

關于TOmcat的一些小小的知識

web.xml中的url-pattern和form 表單中的action是相同的。form 表單中的action聲明的并不是servlet的名字 例&#xff1a; <servlet> <servlet-name>welcome</servlet-name> <servlet-class>WelcomeYou</servlet-class> </servlet> <ser…

Java文件類字符串getAbsolutePath()方法(帶示例)

文件類字符串getAbsolutePath() (File Class String getAbsolutePath()) This method is available in package java.io.File.getAbsolutePath(). 軟件包java.io.File.getAbsolutePath()中提供了此方法。 This method is used to return the absolute path of the file object …

遠控免殺專題(15)-DKMC免殺

0x01 免殺能力一覽表 幾點說明&#xff1a; 1、上表中標識 √ 說明相應殺毒軟件未檢測出病毒&#xff0c;也就是代表了Bypass。 2、為了更好的對比效果&#xff0c;大部分測試payload均使用msf的windows/meterperter/reverse_tcp模塊生成。 3、由于本機測試時只是安裝了360全…

面向對象(靜態成員內部類的調用)

class beyond{public static void main(String []args){//外部類名.內部類名 對象名 外部類名.內部類對象(new 內部類名)/*Outer.Inner yy Outer.new Inner(); 類里面有個非靜態方法&#xff0c;需要new創建Inner對象;正常的形式是這樣的&#xff0c;但是我們習慣將new放在前…

SQL——以面向集合的思維方式來思考

本文來自&#xff1a;http://www.ituring.com.cn/article/details/472 為了以有趣的方式更好地幫助你形成面向集合的思維方式&#xff0c;我將給出自己最喜歡的游戲之一——集合。你可以在線玩這個游戲&#xff0c;網址是www.setgame.com/puzzle/set.htm&#xff0c;每天都會貼…

轉載: 統計圖控件NetCharting 和ZedGraph的比較

原文出處&#xff1a;http://hi.baidu.com/goga/blog/item/07b3024f61b8cd35aec3ab47.html最近考察了幾個統計圖表控件包&#xff0c;開源的有ZedGraph&#xff0c;Nplot等&#xff0c;但是相比之下還是ZedGraph強大&#xff0c;方便一些&#xff0c;其他的感覺還是半成品。收費…

【匯編語言】狀態標志符(CF/OF/SF/ZF)在運算(ADD/SUB/ADC/SBB)過程中的響應變化

目錄各類運算時狀態標志的響應變化標志符在各種ADD運算下的響應情況標志符在各種SUB運算下的響應情況借助標志符實現多位數之間運算ADC(add with carry)帶進位加法指令SBB(subtract with borrow)帶借位減法指令各類運算時狀態標志的響應變化 標志符具體含義CF&#xff08;Carr…

Java集合unmodifiableSortedSet()方法(帶示例)

集合類unmodifiableSortedSet()方法 (Collections Class unmodifiableSortedSet() method) unmodifiableSortedSet() method is available in java.util package. unmodifiableSortedSet()方法在java.util包中可用。 unmodifiableSortedSet() method is used to get a non-modi…

遠控免殺專題(16)-Unicorn免殺

0x01 免殺能力一覽表 幾點說明&#xff1a; 1、上表中標識 √ 說明相應殺毒軟件未檢測出病毒&#xff0c;也就是代表了Bypass。 2、為了更好的對比效果&#xff0c;大部分測試payload均使用msf的windows/meterperter/reverse_tcp模塊生成。 3、由于本機測試時只是安裝了360全…

面向對象(匿名內部類在開發中的應用)

匿名內部類在開發中的應用 public class test1_NoNameInner {public static void main(String[] args) {PersonDemo yy new PersonDemo();//yy.method(new Student());yy.method(new Person() {public void show(){System.out.println("show");}});//匿名內部類當作…

【匯編語言】乘法(MUL/IMUL)

乘法&#xff08;MUL/IMUL&#xff09; 目錄乘法&#xff08;MUL/IMUL&#xff09;IMUL(signed multiply)有符號數乘法MUL(unsigned multiply)無符號數乘法麻&#xff01;屬實是被這個有符號乘法給整麻了&#xff0c;教材就一行例子直接不解釋了&#xff0c;關于標志位溢出的一…

【轉】MFC學習總結

HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if ((pWnd->GetDlgCtrlID() IDC_EDIT1) && (nCtlColor CTLCOLOR_EDIT)) {   COLORREF clr RGB(255,0,0);   pDC->SetTextColor(clr);  //設置紅色的文本   clr RGB(0,0,0…

NHibernate初學體驗進階篇

在上篇《NHibernate初學體檢記》中&#xff0c;我參照NHibernate官方快速指南寫了兩個示例項目&#xff0c;在示例2的源碼中充斥了如下類似的代碼&#xff1a;<?XML:NAMESPACE PREFIX O />Configuration cfg new Configuration(); cfg.AddAssembly("…

eclipse快捷鍵

Java開發工具(Eclipse的視窗和視圖概述) A:視窗 每一個基本的窗體被稱為視窗 PackageExplorer 顯示項目結構&#xff0c;包&#xff0c;類&#xff0c;及資源Outline 顯示類的結構&#xff0c;方便查找&#xff0c;識別&#xff0c;修改Console 程序運行的結果在該窗口顯示Hie…

【匯編語言】除法(DIV/IDIV)

除法&#xff08;DIV/IDIV&#xff09; 目錄除法&#xff08;DIV/IDIV&#xff09;DIV(unsigned divide)無符號數除法IDIV(signed divide)有符號數除法DIV(unsigned divide)無符號數除法 格式&#xff1a;DIV SRC 操作&#xff1a; SRCSRCSRC為字節時&#xff0c;(AL)←(AX)/…

java 方法 示例_Java集合syncedSortedSet()方法與示例

java 方法 示例集合類SynchronizedSortedSet()方法 (Collections Class synchronizedSortedSet() method) synchronizedSortedSet() method is available in java.util package. java.util軟件包中提供了sharedSortedSet ()方法 。 synchronizedSortedSet() method is used to …