# Questions tagged [relational-algebra]

For questions about the algebra of relational model theory, involving operations like Projection (π) Selection (σ), Rename (ρ), and Natural join (⋈).

43 questions
Filter by
Sorted by
Tagged with
15 views

### Relation algebra problem with renaming columns

I am trying to rename a 2 columns after joining them together ρ mmnr←MM.Kortnr, ebnr←EB.Kortnr π Passagerare.Namn, Passagerare.Personnr, MM.Kortnr, EB.Kortnr Passagerare ⟕ Passagerare.Personnr =EB....
14 views

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

How can I calculate the cost of the query, if there is a between condition? Select * From A Where A.id between 10 and 50 If Index not exists and there is only one condition: Search in B+ tree to ...
739 views

### Convert query in words to relational algebra

I have a follow-up question to a question I have previously asked on SO. Instead of the query from my initial question, I want to convert the following into relational algebra: List the names and ...
156 views

### How to reuse a relational algebra expression without using assignment operator?

Can I write the following expression (σθ(R1)) × (σθ(R1)) as (ρR2(σθ(R1))) × R2 ? The first expression is not efficient since I am doing the same operation twice. So, basically, I am looking for ...
68 views

### Bag union operation in relational algebra

I have difficulty in understanding how does the bag union operates in relational algebra? Here, 1) has a schema (X, Y, A) 2) (Y, A) 3) (X, A) 4) (Y, A) so how will output look like after union ...
47 views

### Relational Algebra - Remove duplicate tuples without count

I was wondering if there is a way to remove the tuples from a table using relational algebra that have the same Value occurring in multiple columns or same column multiple times e.g. I want to ...
32 views

### Delete duplicate keys with relation algebra without count

Hi I am new to relational algebra. I was wondering if there is a way to remove the tuples from a table using relational algebra that have the same Value occurring in multiple columns or same column ...
31 views

### Delete duplicate keys with relation algebra

Hi I am new to databases and relational algebra. I was wondering if there is a way to remove the tuples from a table using relational algebra that have the same keys but different value. e.g. I want ...
100 views

### Proof Full Outer Join associative and Commutative

I'm trying to prove to myself that the order of full outer joins doesn't matter, but, in an abstract sense, I'm coming up with nothing. How would one go about proving that the order of a set of FULL ...
22 views

### Using relational algebra to check a condition for all

I encountered this question while revising for my finals exam on database theory. The following database contains information about car repair workshops. The following tables are used: Given two ...
76 views

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

Assuming that we have two tables: Table Q D E a 1 b 2 g 1 Table R D E f 1 b 2 h 3 Show the result of a set difference between tables Q and R. My answer is D E a 1 g 1 But my classmates said the ...
43 views

### Relational Algebra: how to express the combination of aggregation and projection?

Here I have a table, I would like to query the average salary of departments, the SQL statement should be select dept_name, avg(salary) from employee I try to express this SQL in relational algebra....
27 views

### Write aggregate function in select predicate in relational algebra

Can i write aggregate function in select predicate in relational algebra? I am trying to find the maximum salary in the table Employee(name,salary) I am doing this to get max salary. σₛₐₗₐᵣᵧ=Gₘₐₓ₍...
40 views

### Long Relational Algebraic expression provided than actually required

Schema Diagram: Make a list of project numbers for projects that involve an employee whose last name is ‘Smith’, either as a worker or as a manager of the department that controls the project. The ...
1k views

### Theta join explanation

Take the following relational schemes: R(A, B, C) S(D, E, F) where the attributes A and D are the primary keys, respectively. Assume to have an instance r of R with n tuples and an instance s of ...
396 views

I'm following a course in databases (Standford introduction to databases on YT) and, at some point, it's mentioned that t1 INNER JOIN t2 USING attr1, attr2 is equivalent to the NATURAL JOIN symbolized ...
934 views

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

Problem When doing any sort of Join all common attributes are listed under one column in one way or another. However, I have not been able to find a source that deal with columns of the same name, ...
3k views

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

Problem A question I once found on a test was worded as such: Report the book information for the book with ISBN=43221 The relational schema for a book is depicted below: πISBN, title, type, ...
202 views

### Declarative and Procedural Query Languages

In the book Database System Concepts 6th Edition, Chapter 2 (Relational Algebra), it states that there are three formal query languages, the relational algebra, the tuple relational calculus and the ...
472 views

### How to write group by and having in a relational algebra interpreter?

I am practising writing relational algebra (RA) expressions in RA interpreter from Duke, but I can't figure out how to represent group by or having (from SQL). I have this expression, but I need to ...
81 views

### Equi Join On Union- and Intersection-Compatible Relations

Suppose that I have two union- and intersection-compatible relations; i.e., R1(A,B) and R2(C,D) as: Now , I want to find the join of both relations with equality conditions A=C and B=D. I have ...
19 views

### Finding Exclusive Pairings in Relational Algebra

classId | studentId 0 0 0 1 0 2 1 0 1 1 1 2 2 2 How do you find the pairs of students (s1, s2) that ONLY have classes with ...
14 views

### Relation Algebra: Selection of Cartesian Product

I am learning Relational Algebra basics for sql. I came across an example where the selection of cartesian product of two relations (R1 x R2) has been taken and I realize that it is same as selection(...
4k views

### How are joins Commutative and Associative?

I have read all over the place that joins are associative and commutative. So A join (B join C) should be the same as (A join C) join B. But I have a really hard time understanding how this can be ...
43 views

### Question concerning minimal/cannonical cover

For the question above, I am confused with how to approach simplifying the left hand side of BDCE->A. Do I get rid of E, as D depends on it, or do I get rid of CD as well, as CD->A? Here's what I ...
53 views

### Converting from domain calculus to relational algebra

I have an assigned task at the uni and I have the three relations that follow: Customer (Name, City, Account) Offer (Product_Description, Supplier, Price) Order (Name, Product_Description, Quantity,...
2k views

### How to represent NULL in relational algebra?

In the 3rd part of the question below: Study the tables given below and write relational algebra expressions for the queries that follow. STUDENT(+ROLLNO, NAME, AGE, GENDER, ADDRESS, ADVISOR) ...
2k views

### Creating relationships between tables that where not specified in the given UML diagram

Good evening! I'm working on designing my very first actual database from the following UML class diagram (in French unfortunately): I'm at the point of creating the relational sketch of it which I ...
4k views

### Converting SQL to Relational Algebra / Calculus

I have designed a schema and generated a few SQL queries. I'm using PostgreSQL. For example: CREATE TABLE train ( train_code SERIAL PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE journey ( ...
141 views

### How to express inclusive and exclusive relations in relational algebra and relational calculus?

Let be the following simplified database sketch: R1(P,S),R2(S,T) and R3(T,S) with P= people S = Sport and T= Sports Center How to find in relational algebra and relational calculus which couples ...
71 views

### Translating the Relational Algebra output

I have the following relation Jobs(name, company, salary). P1(salary) = πsalary(σcompany='pwc'(Jobs)) P2(salary) = πsalary(ρT1(s)(P1) thetaJoin(s>salary) P1) P3(salary) = P1 − P2 I know that P1 ...
848 views

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

With respect to the operations in relational algebra (not in SQL): I'm having trouble understanding why 2 relations have to be union-compatible before the union operation can be applied on them. I ...
102 views

### Basic Relational Algebra Equivalence

The following relation schema: R(A,C), S(A,D), T(X,Y). Primary key attributes bold Would like to know why the following two are not equivalent queries Q1 = πA(σC<10(R)) and Q2 = σC<10(πA(R)) ...
137 views

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

Problem When there exists two sets, R and S, and we take the difference R - S, we remove the elements from R that exist in S. For cases where the number of columns are the same on both sides, such ...
98 views

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

I have these tables: Sailors sid sname rating age --- ------ ------ --- 22 dustin 7 45 31 john 8 55 58 ben 10 35 Boats ...
185 views

### the verbosity of “(SELECT * FROM A)”?

This might be a novice question. But sometimes, I find it necessary to use things like (SELECT * FROM A) in doing relational algebra in SQL (instead of using the relation A itself). For example, ...
3k views

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

Suppose I have a table of students, containing their ID, grade and state: ------------------------- | id | grade | state | ------------------------ | 1 | 83 | CA | | 2 | 94 | TX ...
27 views

### Do Selection attributes have to appear in Projection list in Relational Algebra

In extended relational algebra (aggregation being allowed) do you have to project all attributes that you use in a statement? So for example in the query below the attributes A.FO_ID and A.Arrival are ...
285 views

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

I have go through this but I couldn't understand. Can I join reation without primary key or partial key? If yes what is the answer for following question.
4k views

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

So I have a table similar to this one. Each user has posted a review about one or more hotels(A,B,C,D) but on different dates so there are no duplicate tuples even though a person might have reviewed ...
129 views

### Relational Algebra Equivalence (basic)

I'm just getting started on an intro to databases course and have a question about writing relational algebra expressions. Schema: Person ( name, age, gender ) Frequents ( name, pizzeria ) Eats ( ...