Skip to content
Sahithyan's S3
1
Sahithyan's S3 — Database Systems

Relational Algebra

An atomic value.

Allowed values for a given attribute. null is a special value which is an element of all domains.

A set of attributes. Denoted as R(A1,A2,,An)R(A_1, A_2, \ldots, A_n).

Given a set of relation schemas D1,D2,,DnD_1, D_2, \ldots, D_n, a relation is a subset of D1×D2××DnD_1 \times D_2 \times \ldots \times D_n.

rD1×D2××Dnr \subseteq D_1 \times D_2 \times \ldots \times D_n

A set of n-tuples.

Represents a record. Element of a relation.

t=(a1,a2,,an)  whereaiDit = (a_1, a_2, \ldots, a_n)\;\text{where} a_i \in D_i

Current values of a relation. Represented by a table.

Let KRK \subseteq R.

KK is a superkey iff values for KK are sufficient to identify a unique tuple of each possible relation r(R)r(R).

KK is a superkey iff:

t1,t2r,t1[K]=t2[K]    t1=t2\forall t_1, t_2 \in r, t_1[K] = t_2[K] \implies t_1 = t_2

No two different tuples have the same values for attributes in KK.

A minimal superkey. KK is a candidate key iff:

  • Kis a superkeyK\,\text{is a superkey} AND
  • KK,Kis a superkey\nexists\, K' \subset K, K'\,\text{is a superkey}

A superkey that is chosen as the main identifier of tuples in RR. Depends on the attributes.

Value in one relation must appear in another.

A theoritical procedural query language. Defines a set of operations that take one or more relations as input and produce a new relation as output.

Extracts tuples (rows) satisfying a specified condition. Denoted by σσ.

σcondition(s)(R)σ_{\text{condition(s)}}(R)

Extracts specific attributes (columns) from a relation. Denoted by ππ.

πattribute list(R)π_{\text{attribute list}}(R)

Duplicates are removed by default, as it is a set. Useful for narrowing down the output to required columns.

Combines tuples from two relations. Denoted by \cup.

RSR \cup S

Result includes all tuples that appear in either or both relations. Both relations must be union-compatible.

2 relations are union-compatible iff both have the equal number of attributes and associated attributes have equivalent domains.

Finds tuples that appear in one relation but not in another. Denoted by -.

RSR − S

Requires union compatibility. Used to find “exclusive” records.

Combines every tuple of one relation with every tuple of another. Denoted by ×\times.

R×SR \times S

If RR has mm tuples and SS has nn tuples, result has m×nm × n tuples. Attributes of both relations are concatenated.

Assigns new names to relations or attributes. Denoted by ρ\rho.

ρnewName(attribute-list)(R)\rho_{\text{newName(attribute-list)}}(R)

Used to avoid ambiguity, especially in self-joins or nested queries.

Combines tuples from two relations based on matching attribute names and matching values. Denoted by .

RconditionSR ⋈_{\text{condition}} S

Finds tuples in one relation associated with all tuples in another. Denoted by ÷\div.

R÷SR \div S

Typically, RR has attributes (A,B)(A, B) and SS has attributes (B)(B). Result contains those AA values that appear with every BB value in SS.