The document discusses the relational model and relational algebra operations. It describes the structure of a relational database as consisting of tables with rows and columns. The fundamental relational algebra operations are select, project, cartesian product, rename, union, and difference. Additional operations like intersection, join, and divide are also covered. The document concludes with discussing modifications to databases through insert, update, and delete operations.
1. OPaper Name -- Database
System
OStaff -- Ms. D. Saritha M.C.A.,
M.phil.,
OClass -- II Year
OSemester -- IV
OUnit -- II
OTopic -- Relational Model
2.
3. Relational Model
O Structure of Relational Database.
O Fundamental Relational Algebra
Operations.
O Additional Relational Algebra Operations.
O Extended Relational Algebra Operations.
O Null Values.
O Modification of the Database.
4. Structure of Relational
Database
O A relational database consists of a
collection of tables, each of which is
assigned a unique name.
O In a Relational Model the term:
1. Relation is refers to TABLE.
2. Row is refers to TUPLE.
3. Column is refers to ATTRIBUTE.
6. Fundamental Operations
O The basic fundamental relational algebra
operations are:
1. The Select Operations.
2. The Project Operations.
3. The Cartesian-Product
Operations.
4. The Rename Operations.
5. The Union Operations.
6. The Set Difference Operations.
7. 1. The Select Operations
O Select operations select tuples (row) that
satisfy the given predicate (condition) from a
relation (table).
O Select operation is denote by Greek letter
Sigma (σ).
O For example:
σp(r)
Where,
σ stands for selection predicate
r stands for relation
p is prepositional logic formula
8. Example
ID NAME DEPT
20895 Venba English
49085 Nila Maths
38575 Iniya Computer science
σdept=“maths”(staff)
The Staff Relation
ID NAME DEPT
49085 Nila Maths
9. 2. The Project Operations
O It projects column(s) that satisfy a given
predicate.
O It is denoted by π
O For example:
πreg-no, name (student).
10. 3. The Cartesian-Product
Operations
O Combines information of two different
relations into one.
O It is denote by X.
O For example:
r X s
Where,
r and s are relations of this cartesian
product.
11. 4. The Rename Operations
O The rename operation allows us to
rename the output relation.
O It is denoted by ρ
O For example:
ρ x (E)
Where,
The result of expression E is saved with
name of X.
12. 5. The Union Operations
O It performs binary union between two
given relations.
O It is denoted by U.
O For example:
r U s
Where ,
r and s must have the same number of
attributes.
13. 6. The Set Difference
Operations
O The result of set difference operation is
tuples, which are present in one relation
but are not in the second relation.
O It is denoted by –
O For example:
r – s.
14. Additional Operations
O Additional operations are defined in terms
of the fundamental operations.
O They do not add power to the algebra, but
are useful to simplify common queries.
O The additional operations are:
1. The Set Intersection Operation
2. The Natural Join Operation
3. The Division Operation
4.The Assignment Operation
15. The Set Intersection
O It is denoted by ∩, and returns a relation that
contains tuples that are in both of its argument
relations.
O For example
O r∩ s=r-(r-s)
The Natural Join
O The natural join is a binary operation that allows
us to combine certain selection and a cartesian
product into one operation.
The Division Operations:
O Division, denoted , is suited to queries that include
the phrase ``for all''.
The Assignment Operation:
O The assignment operation, denoted , works like
assignment in a programming language.
16. Extended Operations
O Extended operators are those operators
which can be derived from basic
operators.There are mainly three types of
extended operators in Relational Algebra:
O Join
O Intersection
O Divide
17. Modification of Database
O Modification statements make changes to
database data in tables and columns.
O There are 3 modification of database:
1) Insert – add rows to tables.
2) Update – modify columns in table
row
3) Delete – remove rows from tables
18. 1) Insert
O The Insert statement adds one or more
rows to a table.
O Syntax :
insert into table_name (column-list) values
(values-list)
(OR)
insert into table_name (column-list)
(query-specification)
19. Example:
O insert into student (reg-no, name, dept)
values (103, ‘Riya’, ‘physics’)
REG-NO NAME DEPT
101 Thiya Maths
102 Malar English
REG-NO NAME DEPT
101 Thiya Maths
102 Malar English
103 Riya Physics
20. 2) Update
O The Update statement modifies columns
in selected table rows.
O Syntax:
update table_name Set (set-list) [Where
predicate].
O The Set Clause expressions and Where
Clause predicate can contain subqueries.
O The set-list contains assignments of new
values for selected columns.
21. Example
O update student set dept = Info _Tech
where reg-no =102
REG-NO NAME DEPT
101 Vijay Computer science
102 Suriya Info_tech
REG-NO NAME DEPT
101 Vijay Computer science
102 Suriya Null
22. 3) Delete
O The delete statement removes selected
rows from a table. We cannot delete
values on only particular attributes. We
can delete only whole tubles.
O Syntax:
delete from table_name [where
predicate]
23. Example
O delete from student where name =
‘Veera’
REG-NO NAME DEPT
306 Vijay Computer science
307 Veera Mechanical
308 Vishnu Info-tech
REG-NO NAME DEPT
306 Vijay Computer science
308 Vishnu Info-tech