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

DBMS 5

Chapter 5 discusses the relational model and relational algebra, emphasizing the organization of data into inter-related tables known as relations, where rows are tuples and columns are attributes. It covers key concepts such as domains, relational schemas, constraints, and the characteristics of relations, including tuple uniqueness and referential integrity. Additionally, it introduces unary and binary relational operations, particularly the select and project operators in relational algebra.

Uploaded by

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

DBMS 5

Chapter 5 discusses the relational model and relational algebra, emphasizing the organization of data into inter-related tables known as relations, where rows are tuples and columns are attributes. It covers key concepts such as domains, relational schemas, constraints, and the characteristics of relations, including tuple uniqueness and referential integrity. Additionally, it introduces unary and binary relational operations, particularly the select and project operators in relational algebra.

Uploaded by

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

ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

CHAPTER 5 : RELATIONAL MODEL AND RELATIONAL


ALGEBRA

INTRODUCTION:
• In relational data model, the data and relationships are represented by collection
of inter-related tables.
• Each table is a group of columns and rows, where column represents attributes of
an entity and row represents records.
• In relational data model,
✓ a row is called as tuple
✓ a column header is called an attribute
✓ the table is called a relation

RELATIONAL MODEL CONCEPTS:


Domain:
• A domain is a unique set of values permitted for an attribute in a table.
• Domain is atomic.
• Example:
✓ A domain of month-of-year can accept January, February to December as
possible values.
✓ A domain of mobile numbers: the set of 10 digit positive numbers
✓ A domain of Aadhar number: the set of valid 12 digit positive numbers.

Relation:
• The relational model for database management is an approach to logically
represent and manage the data stored in a database.
• In this model, the data is organized into a collection of two-dimensional inter-
related tables, also known as relations.
• Each relation is a collection of columns and rows, where the column represents
the attributes of an entity and the rows (or tuples) represent the records.

BHAVYA C 1
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

Relational Schema:
• It is the logical blueprint of the relation i.e., it describes the design and the
structure of the relation. It contains the table name, its attributes, and their types:
• TABLE_NAME (ATTRIBUTE_1 TYPE_1, ATTRIBUTE_2 TYPE_2, ...)
• For our student relation example, the relational schema will be:
• STUDENT (ROLL_NUMBER INTEGER, NAME VARCHAR (20), CGPA FLOAT)

Degree: It is the total number of attributes present in the relation.


Cardinality: It specifies the number of entities involved in the relation i.e., it is the total
number of rows present in the relation.
Relation Instance: it is a finite set of tuples in the relational DBMS system.
Relation State: Relation Instance at a particular moment in time.
Relational database schema: it contains a set of relational schemas and integrity
constraints such as entity integrity constraint, referential integrity constraint and domain
constraints.
Relational database State: a set of relational schema states at a particular moment in
time is called as relational database state.

BHAVYA C 2
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

CHARACTERISTICS OF A RELATION:
1. Ordering of tuples in a relation: A relation is defined as a set of tuples.
Mathematically, elements, of a set have no order among them; hence, tuples in a
relation do not have any particular order. In other words, a relation is not a
sensitive to the ordering of tuples.

2. Ordering of Attributes in a Relation: the ordering of attributes is not important,


because the attribute name appears with its value. When a relation is implemented
as a file, the attributes and the values within tuples are ordered.

3. Values and NULLs in the tuples: Each value in a tuple is an atomic value. A special
null value is used to represent values that are unknown or inapplicable to certain
tuples.

4. Interpretation (Meaning)of relation: The relation schema can be interpreted as


a declaration or as a declaration or a type of assertion. For example, the schema of
the STUDENT relation asserts that, in general ,a student entity has a name, age,
address, course, marks and so on.

CONSTRAINTS ON RELATIONS:

• A property assigned to a table column that prevents certain types of invalid data
values from being placed in the column.

CATEGORIES OF CONSTRAINTS:
1. Inherent model-based constraints:
constraints that are inherent in the definition/assumptions of a particular data
model hold in every database having that data model as its underpinning.
Example: In the relational model, no two tuples in a relation can be duplicates.

2. Schema based constraints:


Constraints that are directly applied in the schemas of the data model, by
specifying them in the DDL (Data Definition Language). These are called Schema-
Based Constraints or Explicit Constraints.
• Domain Constraints
• Key Constraints
• Constraints on null
• Entity Integrity Constraints
• Referential integrity Constraints

BHAVYA C 3
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

3. Application based constraints:


Constraints that cannot be directly expressed in the schemas of the data model,
and hence must be expressed and enforced by the application programs.

4. Data Dependencies constraints:


This constraint includes functional dependencies and multivalued dependencies.
These constraints are used for testing the goodness of the design of a relational
database.

RELATIONAL CONSTRAINTS IN DBMS:

BHAVYA C 4
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

DOMAIN CONSTRAINT:
• Domain constraint defines the domain or set of values for an attribute.
• It specifies that the value taken by the attribute must be the atomic value
from its domain.
• Example- Consider the following Student table-

Here, value ‘A’ is not allowed since only integer values can be taken by the age
attribute.

TUPLE UNIQUENESS CONSTRAINT:


Tuple Uniqueness constraint specifies that all the tuples must be necessarily
unique in any relation.
Example-01: Consider the following Student table-

This relation satisfies the tuple uniqueness constraint since here all the tuples are
unique.

BHAVYA C 5
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

Example-02: Consider the following Student table-

This relation does not satisfy the tuple uniqueness constraint since here all the
tuples are not unique.

KEY CONSTRAINT:
Key constraint specifies that in any relation:
✓ All the values of primary key must be unique.
✓ The value of primary key must not be null.

This relation does not satisfy the key constraint as here all the values of primary
key are not unique.

BHAVYA C 6
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

ENTITY INTEGRITY CONSTRAINT:


• Entity integrity constraint specifies that no attribute of primary key must
contain a null value in any relation.
• This is because the presence of null value in the primary key violates the
uniqueness property.

This relation does not satisfy the entity integrity constraint as here the primary key
contains a NULL value.

REFERENTIAL INTEGRITY CONSTRAINT:


• This constraint is enforced when a foreign key references the primary key of
a relation.
• It specifies that all the values taken by the foreign key must either be available in
the relation of the primary key or be null.
• Example- Consider the following two relations- ‘Student’ and ‘Department’.
Here, relation ‘Student’ references the relation ‘Department’.

BHAVYA C 7
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

• Here, The relation ‘Student’ does not satisfy the referential integrity
constraint.
• This is because in relation ‘Department’, no value of primary key specifies
department no. 14.
• Thus, referential integrity constraint is violated.

BHAVYA C 8
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

RELATIONAL ALGEBRA:
• The relational algebra is a procedural query language.
• It consists of a set of operations that take one or two relations as input and produce
a new relation as their result.

UNARY RELATIONAL OPERATIONS:


The SELECT and PROJECT are the unary operators because these operators are applied
to a single relation.
1. Select Operator:
• Select operation is done by Selection Operator which is represented by "sigma"(σ).
• It is used to retrieve tuples(rows) from the table where the given condition is
satisfied.
• It is a unary operator means it requires only one operand.
• Syntax : σ <selection_condition>(R)
Where σ is used to represent SELECTION
R is used to represent RELATION

BHAVYA C 9
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

Selection_condition is the logic formula

• Example:

Suppose we want the row(s) from STUDENT Relation where "AGE" is 20


σ AGE=20 (STUDENT)

2. Project operator:
• 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.
• It is also a unary operator.
• syntax : ∏ a(r)
Where ∏ is used to represent PROJECTION
r is used to represent RELATION
a is the attribute list
• Suppose we want the names of all students from STUDENT Relation.
∏ NAME(STUDENT)

BHAVYA C 10
ST FRANCIS COLLEGE – DEPT OF CSA DBMS – CHAP 5

BINARY RELATIONAL OPERATIONS: (refer lecture notes)


ADDITIONAL RELATIONAL OPERATIONS: (refer lecture notes)
EXAMPLES OF QUERIES IN RELATIONAL ALGEBRA: (refer lecture notes)

BHAVYA C 11

You might also like