relational-algebra

How to implement relational equivalent of the DIVIDE operation in SQL Server

♀尐吖头ヾ 提交于 2021-02-19 03:21:08
问题 I was reading relational algebra from one of the textbook. I came across DIVIDE operation. From Wikipedia: The division is a binary operation that is written as R ÷ S. The result consists of the restrictions of tuples in R to the attribute names unique to R, i.e., in the header of R but not in the header of S, for which it holds that all their combinations with tuples in S are present in R. Thus if R is: +----+----+ | A | B | +----+----+ | a1 | b1 | | a2 | b1 | | a3 | b1 | | a4 | b1 | | a1 |

Query using aggregation and/or groups in relational algebra - count, max, min, etc

断了今生、忘了曾经 提交于 2021-02-08 05:13:07
问题 I have read much in textbooks and browsed a lot of pages on the internet but I can't understand how functions/operators like min, max, count, ... that aggregate over a relation/table or groups of tuples/rows in a relation/table are built with basic operations such as ∪ (union), ∩ (intersection), x (join), - (minus), π (projection), .... Can anyone show me how to express these functions/operators with relational algebra? 回答1: Computing functions in relation algebra are not fully included yet.

Query using aggregation and/or groups in relational algebra - count, max, min, etc

半腔热情 提交于 2021-02-08 05:11:06
问题 I have read much in textbooks and browsed a lot of pages on the internet but I can't understand how functions/operators like min, max, count, ... that aggregate over a relation/table or groups of tuples/rows in a relation/table are built with basic operations such as ∪ (union), ∩ (intersection), x (join), - (minus), π (projection), .... Can anyone show me how to express these functions/operators with relational algebra? 回答1: Computing functions in relation algebra are not fully included yet.

How to list each pair of tuple only once irrespective of column order in SQL and relational algebra?

倖福魔咒の 提交于 2021-01-27 13:15:56
问题 I'm working on some book exercises and can't find an explanation on how to express the following in relational algebra. I did find an answer for SQL though but I'm interested in whether there are any alternatives to solve it. The question from the book is: Find those pairs of PC models that have both the same speed and RAM. A pair should be listed only once; e.g., list(i,j) but not (j,i). The schema for PC is: PC ( model INTEGER NOT NULL PRIMARY KEY, speed NUMERIC, ram INTEGER, hd INTEGER,

How to express “no information” in relational algebra?

吃可爱长大的小学妹 提交于 2020-05-28 11:42:48
问题 A task that I'm working on to learn relational algebra is asking me to find the clients who want to rent a property for free, or have not given information about how much they are willing to pay. the table looks like this: Client(clientNo, firstName, lastName, maxRent) I have some trouble finding any information about how to represent a lack of information, or an empty data point.. so far I've come up with this where half of the expression is psuedo code: σ maxRent = 0 OR [no info given]

How to express “no information” in relational algebra?

回眸只為那壹抹淺笑 提交于 2020-05-28 11:40:46
问题 A task that I'm working on to learn relational algebra is asking me to find the clients who want to rent a property for free, or have not given information about how much they are willing to pay. the table looks like this: Client(clientNo, firstName, lastName, maxRent) I have some trouble finding any information about how to represent a lack of information, or an empty data point.. so far I've come up with this where half of the expression is psuedo code: σ maxRent = 0 OR [no info given]

Selecting DISTINCT rows in relational algebra

左心房为你撑大大i 提交于 2020-04-06 04:19:22
问题 There is a DISTINCT operator in SQL. However, I have an assignment in which I need to get some distinct values from a table, and I can only use relational algebra. Is there a way? 回答1: Relational projections always return distinct tuples so DISTINCT is never needed. Duplicate tuples are not permitted in the RA - that being one major difference between the relational model and the SQL model. 回答2: Relational Algebra is based on set theory. SQL is an implementation of multi-set theory. Set

Null in Relational Algebra

老子叫甜甜 提交于 2020-03-19 06:11:59
问题 I want to query the id of all apartments that were never rented I tried something like this: (π a_id (apartments)) - (π a_id σ from_date Exists ∧ end_date Exists (rental) ⨝ rental.a_id on apartment.a_id (apartment)) But I think I cannot use Exist in relational algebra or null or anything. How could I do it? Thanks I attach the schema here 回答1: For the most straightforward relational algebra, where a relation has an attribute set as heading & tuple set as body: Presumably apartment ids in