# Tag Info

## Hot answers tagged relational-algebra

### the verbosity of "(SELECT * FROM A)"?

If you want shorter syntax in SQL, there is the TABLE name syntax that you can use - where name is a table name (base table or view or cte): SELECT * FROM ((TABLE A) UNION (TABLE B)) t ; The ...
• 98.2k
Accepted

### Proof that Inner Join is Commutative

An inner join is the subset of rows from the cartesian product where a certain condition is true. Although the cartesian product is not commutative (nor associative), it is with regard to relational ...
• 13.5k
Accepted

### How are joins Commutative and Associative?

You've made an incorrect assumption. If three's a relationship between A and B, and between B and C but no relationship between A and C, joining A and C doesn't give you no rows. It actually gives ...
• 11.6k
Accepted

### Is there a shortcut for 'SELECT * FROM table' in relational algebra?

Yes. In relational algebra the relation Book corresponds to select * from Book If you want to restrict to some rows you apply a selection σ: σISBN=43221(Book) In SQL this is a where-...
• 7,692
Accepted

### Do my relational algebra operations produce the desired results?

This is indeed the error: R4 := R2 ∩ R3 If we try to get the intermediate results of your solution, we get: R1: bid bname color sid date --- --------- ----- --- -...
• 98.2k
Accepted

### Long Relational Algebraic expression provided than actually required

Trying to find a simpler solution is admirable, but your expression is subtly wrong. The important part of the question is: ...or as a manager of the department... Notice, that's not the same as "...
• 1,817
Accepted

### Minimum and Maximum Number of Tuples

Yes, your answers are mostly right, except a few mistakes: 1. R UNION S max : n+m ( union we add all the tuples from both relations) Correct, when R and S have no common tuple. min: 0 ( taking m=n=...
• 98.2k
Accepted

### Prove that R ⟕ S = R ⨝ S

Since {R.b} is the foreign key referencing S, each tuple in R is guaranteed to have one and only one matching tuple in S, therefore the natural join will result in all R tuples being selected exactly ...
• 26.3k
Accepted

### Unsure how to formulate Relational Algebra Query

As you note, A ∪ B returns A if B = ∅, otherwise it returns tuples from both A and B. In other words, the result is correct, except it includes A when B is non-empty. You need an extra expression E, ...
• 86.4k

### Show the result of a set difference between tables Q and R

Here is what you looking at (Set Difference) Q - R Set Q Minus Set R In MySQL SELECT Q.* FROM Q LEFT JOIN R USING (D, E) WHERE R.E IS NULL; Here is what the classmates are saying (Symmetric ...
• 183k

### Translating the Relational Algebra output

P2(salary) = πsalary(ρT1(s)(P1) thetaJoin(s>salary) P1) From the Wikipedia entry for Relational Algebra: The result of the θ-join is defined only if the headers of S and R are disjoint, that is, ...
• 86.4k
Accepted

### Question concerning minimal/cannonical cover

The algorithm to compute the minimal cover of a set of dependencies requires that, when there are multiple attributes on the left part, we should eliminate the extraneous ones, that is the attributes ...
• 4,080

### How to represent NULL in relational algebra?

There are no NULL values in relational algebra. Here you can use the antijoin operator ▷: πROLLNO, NAME(STUDENT ▷ENROLLMENT) that selects all records from STUDENT where the ROLLNO is ...
• 7,692

### How are joins Commutative and Associative?

Considering A, B and C are three tables join operation is denoted by ⋈ Sets (circles in below venn diagram) are formed according to the join columns, that is A ⋈ B represents set of rows having same ...
• 249
Accepted

### Counting distinct entries in a column using relational algebra

Besides the more compact syntax (from @McNets' answer): select User, count(distinct Hotel_Reviewed) HotelsReviewed from InitialRelation group by User; we can also do a projection ...
• 98.2k
Accepted

### Is it posible to join relation without primary key attribute?

Yes, you can join on any columns in a query. Primary and Foreign Keys are for Referential Integrity. Select Item.IName, Item_Supply.AvailableQuantity From Item Join Item_Supply ON Item.ItemKey = ...
• 453
Accepted

### Why is it called "semi-join"?

"from one dataset"--of two. 1/2. "semi". The paper that introduced the term is Using Semi-Joins to Solve Relational Queries by Bernstein and Chiu (1981). this operator, which we ...
• 778

### Converting SQL to Relational Algebra / Calculus

You have a number of "mistakes" in your SQL, that should be addressed before you translate it to relational algebra. You don't have a FROM in your SQL. You shouldn't start by JOINing. You seem to ...
• 13.5k
Accepted

### Find the highest graded student in each state, using Relational Algebra

I'll do it first using standard SQL and then use a tool called RelaX--relational algebra calculator 0.18.2 to do the translation. Define and fill the table: CREATE TABLE students ( id INTEGER ...
• 13.5k
Accepted

### Difference of sets with different amount of columns?

If I recall, the difference operation requires the two relations involved to be compatible, implying that they should have the same number of columns. Quoting from Wikipedia about relational algebra ...
• 3,610
Accepted

### Equivalent of SQL’s "INNER JOIN USING" in relational algebra

Relational natural join is more or less SQL natural join. SQL natural join is defined as SQL inner join using all common columns. (And it is only defined when each argument has exactly one column with ...
• 778
Accepted

### Bag union operation in relational algebra

After giving this question little thoughts, I found, I was missing the projection part which means the only attribute A is considered for the union. So, basically all we have to do is grouping using ...
• 127
Accepted

### FInd minimum and maximum number of tuples in R U πA,B ( R⋈S )

In general a Union doesn't 'filter out' any tuples, then the cardinality of the result is at least the cardinality of the higher-cardinality operand. The Projection is on to the original heading of R, ...
• 218

### Relational Algebra Practice Question

Forget the algebra. Your model - or how you are describing it - is fundamentally wrong. ... a table Movies that has primary key attribute Lead_Actor ... The primary key of a Movies able MUST be ...
• 8,860
1 vote

### How can I calculate the cost of the query, if there is a `between` condition?

If there is no index for A.id column, then database engine perform full table scan. So O(N) operations are performed. If there is a B+tree index for A.id then database optimizer may choose it, if ...
1 vote
Accepted

### Declarative and Procedural Query Languages

The writing is poor. "Declarative" is informal & they use it it in two ways. The general meaning is, "describe a result (not a process)". But many descriptions of results have an obvious ...
• 778
1 vote

### Nontrivial joining a relation with itself

What you describe is simply a projection of R that includes a twice. There is no need for "renaming and natural join operations on R".
• 26.3k
1 vote
Accepted

### Can a Join happen with same attribute names, but different domains?

I think you are being misled by your terminology. SQL is a standard that has the following schematics Schema Table Column Attribute *Oracle does not have separate databases in an Instance. schemas ...
• 677
1 vote

### Why does the UNION operation require that the relations on which they are applied be union compatible?

Well, my answer may not be serving your question but what you are asking is to have an OUTER UNION as suggested by @Lennart. The result you are expecting is what OUTER UNION will give you. Whereas ...
• 111
1 vote

### Minimum and Maximum Number of Tuples

I have recompiled the above answer more lucidly and added some more relational algebra operations. Hope, it's useful :) Consider Relations R and S where R is having m tuples and S is having n tuples. ...

Only top scored, non community-wiki answers of a minimum length are eligible