Attribute
An atomic value.
Domain
Allowed values for a given attribute. null is a special value which is an element of all domains.
Relation Schema
A set of attributes. Denoted as .
Relation
Given a set of relation schemas , a relation is a subset of .
A set of n-tuples.
Tuple
Represents a record. Element of a relation.
Relation Instance
Current values of a relation. Represented by a table.
Keys
Let .
Superkey
is a superkey iff values for are sufficient to identify a unique tuple of each possible relation .
is a superkey iff:
No two different tuples have the same values for attributes in .
Candidate Key
A minimal superkey. is a candidate key iff:
- AND
Primary Key
A superkey that is chosen as the main identifier of tuples in . Depends on the attributes.
Foreign Key
Value in one relation must appear in another.
Relational Algebra
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.
Selection
Extracts tuples (rows) satisfying a specified condition. Denoted by .
Projection
Extracts specific attributes (columns) from a relation. Denoted by .
Duplicates are removed by default, as it is a set. Useful for narrowing down the output to required columns.
Union
Combines tuples from two relations. Denoted by .
Result includes all tuples that appear in either or both relations. Both relations must be union-compatible.
Union Compatible
2 relations are union-compatible iff both have the equal number of attributes and associated attributes have equivalent domains.
Set Difference
Finds tuples that appear in one relation but not in another. Denoted by .
Requires union compatibility. Used to find “exclusive” records.
Cartesian Product
Combines every tuple of one relation with every tuple of another. Denoted by .
If has tuples and has tuples, result has tuples. Attributes of both relations are concatenated.
Rename
Assigns new names to relations or attributes. Denoted by .
Used to avoid ambiguity, especially in self-joins or nested queries.
Natural Join
Combines tuples from two relations based on matching attribute names and matching values. Denoted by .
Division
Finds tuples in one relation associated with all tuples in another. Denoted by .
Typically, has attributes and has attributes . Result contains those values that appear with every value in .