logo
Home Handwritten Notes

Modification of the Database

Engineering → Computers Science And Engineering → Data Base Management System → Relational Algebra

Complete digital notes on Modification of the Database. Study this topic thoroughly with our comprehensive notes and examples.

Modification of the Database

The content of the database may be modified using the following operations:

All these operations are expressed using the assignment operator ( ←).

1.Deletion

A delete request is expressed similarly to a query, except instead of displaying tuples to the user, the selected tuples are removed from the database.

In deletion, tuples are deleted from the relation.

You can only delete whole tuples; you cannot delete values from specific attributes.

A deletion is expressed in relational algebra by: r ← r - E

Where r is a relation and E is a relational algebra expression.

Example _of_Deletion

2.Insertion

Similar to deletion, but uses the union operator (∪) instead of the difference operator (-).

In insertion, tuples are added to the relation.

To insert data into a relation, you can either:

Specify a tuple to be inserted, or

Write a query whose result is a set of tuples to be inserted.

An insertion is expressed in relational algebra by: r ← r ∪ E

Where r is a relation and E is a relational algebra expression.

The insertion of a single tuple is expressed by letting E be a constant relation containing one tuple.

Example _of_insertion Examples:

1.Insert information into the database specifying that Smith has $1200 in account A-973 at the Perryridge branch.

2.Insert tuples based on the result of a query:

⇒ Provide a $200 savings account as a gift for all loan customers at the Perryridge branch. Let the loan number serve as the account number for the new savings account.

3.Updating

Updating is a mechanism to change a value in a tuple without changing all values in the tuple.

Use the generalized projection operator to perform this task.

Each Fi can be either:

The attribute of r, or

An expression involving only constants and the attributes of r that gives the new value for the attribute.

Note:The schema of the expression resulting from the generalized projection expression must match the original schema of r.

Example
description of faastop website
logo