Skip to main content
7 votes

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 ...
ypercubeᵀᴹ's user avatar
6 votes
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 ...
joanolo's user avatar
  • 13.5k
6 votes
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 ...
RDFozz's user avatar
  • 11.6k
6 votes
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-...
miracle173's user avatar
  • 7,692
6 votes
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 --- --------- ----- --- -...
ypercubeᵀᴹ's user avatar
5 votes
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 "...
Doug Deden's user avatar
  • 1,817
4 votes
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=...
ypercubeᵀᴹ's user avatar
4 votes
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 ...
mustaccio's user avatar
  • 26.3k
3 votes
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, ...
Paul White's user avatar
  • 86.4k
3 votes

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 ...
RolandoMySQLDBA's user avatar
3 votes

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, ...
Paul White's user avatar
  • 86.4k
3 votes
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 ...
Renzo's user avatar
  • 4,080
3 votes

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 ...
miracle173's user avatar
  • 7,692
3 votes

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 ...
RajS's user avatar
  • 249
3 votes
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 ...
ypercubeᵀᴹ's user avatar
3 votes
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 = ...
SS_DBA's user avatar
  • 453
3 votes
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 ...
philipxy's user avatar
  • 778
2 votes

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 ...
joanolo's user avatar
  • 13.5k
2 votes
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 ...
joanolo's user avatar
  • 13.5k
2 votes
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 ...
tinlyx's user avatar
  • 3,610
2 votes
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 ...
philipxy's user avatar
  • 778
2 votes
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 ...
ssp4all's user avatar
  • 127
2 votes
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, ...
AntC's user avatar
  • 218
2 votes

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 ...
Phill  W.'s user avatar
  • 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 ...
philipxy's user avatar
  • 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".
mustaccio's user avatar
  • 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 ...
clifton_h's user avatar
  • 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 ...
karan patel's user avatar
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. ...
Well_Wisher's user avatar

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