0% found this document useful (0 votes)
11 views

DBMS Unit 3

Uploaded by

sujatasonar1975
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

DBMS Unit 3

Uploaded by

sujatasonar1975
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Unit – III Relational Data Model

Relational Data Model :

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.

The concepts of Relational Model in DBMS


1. Relation: A relation is a table which is a combination of rows or tuples
and columns.
2. Attributes: An attribute represent the unique name for each column so
that a particular column gets the identity.
3. Domain: A domain tells which type of value can be stored in a particular
column, in the Roll No column it will always accept the integer value, but
it won’t accept the string value. So, the domain in Relational Model in
DBMS is also defined as the set of allowable values for all the attributes
in the tables.
4. Tuples: Tuples represent the rows of a relation.
5. Relation Schema: The name of the relations with its attributes is
represented by the relation schema.
6. Relation Instance (State): Relation Instance makes sure that there are no
duplicate rows present in the table. So, it is nothing but it is a finite set of
rows or tuples.
7. Degree: Degree is represented by the total number of attributes or
columns present in the relation or table.
8. Cardinality: Cardinality is just the opposite of the degree, it is
represented by the total number of rows present in the relation or table.
9. Relation Key: The relation key in Relational Model in DBMS is also
known as the primary key, It is used to uniquely identify each row in the
table.

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.

2) Ordering of values within a tuple :


 By the definition of a tuple, An n-tuple is a ordered list of n values,
so we cannot interchange the value within a tuple according to this
definition , hence the ordering of values within a tuple is important.
 With an alternative definition of tuple, Ordering of values in a tuple
is unnecessary.
 i.e, A tuple is a set of (<attribute>,<value>) pair, then ordering of
values in a tuple is not important. Because in this type of tuple, the
attribute name and the corresponding values are mentioned together .
even if we interchange the values, the meaning of a tuple will remain
same.

3) Values and nulls in a tuple :


 Each value in a tuple should be a atomic value(indivisible-the value
that cannot be divided further). Hence a relation does not allow
composite or multivalued attribute in a tuple.
 There can be null values for the attributes.
 Null values are the values that are unknown or values that does not
exist for that particular attribute.

4)No two tuples are identical in a relation :

 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 :

 A relation can be used to interpret facts about entitites as a type of


assertion.
 A relation can also be used to interpret facts about relationships.

Relational Model Constraints :


1) Domain Constraint:
 Every domain must contain atomic values(smallest indivisible units)
which means composite and multi-valued attributes are not allowed.

 We perform a datatype check here, which means when we assign a


data type to a column we limit the values that it can contain. Eg. If we
assign the datatype of attribute age as int, we can’t give it values other
than int datatype.

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.

Basic relational algebra Operations:

Unary relational algebra operations:

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 :

Project operation is done by Projection Operator which is represented by "pi"(∏).


It is used to retrieve certain attributes(columns) from the table. It is also known
as vertical partitioning as it separates the table vertically.

3) Rename Operation :

Rename operation is denoted by "Rho"(ρ). As its name suggests it is used to


rename the output relation

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).

 Duplicate tuples are eliminated automatically.


2) Intersection operation :

o Suppose there are two tuples R and S. The set intersection operation
contains all tuples that are in both R & S.

o It is denoted by intersection symbol ∩.


3)Minus operation :

Suppose there are two tuples R and S.

R-S : includes all the tuples that are in R but not in S.


S-R : includes all the tuples that are in S but not in R.

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.

You might also like