Darkstarone
Darkstarone

Reputation: 4730

Relational Algebra: Select tuples based on whether an attribute is unique in a table

Given a table:

T = {A1, A2, A3, A4}

How do you write a relational algebra statement that picks all tuples that have the same value for A3 as another tuple in the table?

Upvotes: 0

Views: 485

Answers (1)

dimm
dimm

Reputation: 1798

You do a equijoin with T and itself on column A3.

T2←T,T⋈T.A3=T2.A3 T2

Now any tuple from T will be connected with all tuples that have the same value for A3. You can further select for a specific value of A3 from T and project to the attributes from T2.

Upvotes: 1

Related Questions