DBMS Unit 3
DBMS Unit 3
The relational model in DBMS is an abstract model used to organize and manage
the data stored in a database. It stores data in two-dimensional inter-related tables,
also known as relations in which each row represents an entity and each column
represents the properties of the entity.
10.Tuple Variable: Tuple Variable represents all the data that are stored in a
record of the table or relation.
Characteristics of relations:
1) Ordering of Tuples within a relation :
A relation is a set of tuples.
We know that, Mathematically the elements in the set do not follow any
order and theoretically, the relational data model obeys the set theory so the
tuples in a relation need not follow any order.
If the tuples are interchanged also, the information and meaning of relation
remains the same, only the order of the tuple varies. Hence the ordering of
tuples in a relation is irrelevant.
Since a relation is a set of tuples and a set does not have identical
elements. Therefore each tuple in a relation must be uniquely
identified by its contents.
In other words, two tuples with the same value for all the attributes
cannot exist in a relation.
5) Interpretation of a relation :
2) Key Constraints
3) Constraints on null values
4) Primary key constraint or Entity Integrity constraint
5) Foreign key constraint or Referential Integrity constraint
Relational Algebra :
Relational algebra refers to a procedural query language that takes relation
instances as input and returns relation instances as output. It performs queries with
the help of operators. A binary or unary operator can be used.
1) Select Operation :
It is used to retrieve tuples(rows) from the table where the given condition
is satisfied.
Select operation is done by Selection Operator which is represented
by "sigma"(σ)
2) Project operation :
3) Rename Operation :
Notation: ρ(R,S)
Where R is the new relation name
S is the old relation name
Example: We can use the rename operator to rename STUDENT relation to
STUDENT1.
ρ(STUDENT1, STUDENT)
Example 2: simplifying the combined query into separate queries and renaming
the obtained relation with a new name.
Set Theory Operations on relations:
1)Union Operation:
Suppose there are two tuples R and S. The union operation contains all the
tuples that are either in R or S or both in R & S.
It is denoted by ∪.
Union compatibility: R and S must have the attribute of the same number
and same type(Domain type).
o Suppose there are two tuples R and S. The set intersection operation
contains all tuples that are in both R & S.
4) Cartesian Product :
o The Cartesian product is used to combine each row in one table with each
row in the other table. It is also known as a cross product.
o It is denoted by X.