I'm Presentation
I'm Presentation
Presentatio
n
Group Members: To:
Sarbajit Paul Bappy (222-15-6155) Tamanna Sultana
Rittik Chandra Das Turjy (222-15-6289) Lecturer
Maruf Rahman (222-15-6212) Department of CSE
Most. Jannatul Firdousi Zoti (222-15- Daffodil International
6145) University
Topics to Cover
1.Relational
Algebra
2.Transaction
3.SQL Views
4.Join in DBMS
Relational Algebra
Relational algebra is a procedural query language, which takes instances of relations as input and yields
instances of relations as output. It uses operators to perform queries.
Six basic
operators:
• select: σ
• project: ∏
• union: ∪
• set difference: –
• Cartesian product: x
• rename: ρ
Select Operation
The select operation selects tuples that satisfy a given predicate.
• Notation − σp(r)
• p is called the selection predicate
• Query:
Rename Operation
The results of relational algebra are also relations but without any name. The rename
operation allows us to rename the output relation. 'rename' operation is denoted with small
Greek letter rho ρ.
Natation: ρx (E)
Transaction
• A Transaction is a unit of program execution that accesses
and possibly updates various data items.
• A transaction must see a consistent database.
• During transaction execution the database may be
inconsistent.
• When the transaction is committed, the database must be
consistent.
• Two main issues to deal with:
⚬ Failures of various kinds, such as hardware failures
and system crashes
⚬ Concurrent execution of multiple transactions
Transaction Properties
Atomicit Consistenc Isolatio Durabili
y y n ty
• This property states that a • The database must remain • The database should be durable • In a database system where
transaction must be treated in a consistent state after enough to hold all its latest more than one transaction
as an atomic unit, that is, any transaction. No updates even if the system fails are being executed
either all of its operations transaction should have or restarts. If a transaction simultaneously and in
are executed or none. There any adverse effect on the updates a chunk of data in a parallel, the property of
must be no state in a data residing in the database and commits, then the isolation states that all the
database where a transaction database. If the database database will hold the modified transactions will be carried
is left partially completed. was in a consistent state data. If a transaction commits out and executed as if it is
States should be defined before the execution of a but the system fails before the the only transaction in the
either before the execution transaction, it must remain data could be written on to the system. No transaction will
of the transaction or after the consistent after the disk, then that data will be affect the existence of any
execution/abortion/failure of execution of the updated once the system springs other transaction.
the transaction transaction as well. back into action.
Committing a Transaction
COMMIT in SQL is a transaction control language that is used to permanently save the changes done in the
transaction in tables/databases. The database cannot regain its previous state after its execution of commit.
Syntax: ROLLBACK; or
ROLLBACK [TO SAVEPOINT < savepoint_name>];
Transaction Control
• Used with the rollback command in SQL.
• Marks transactions in a table.
• Ideal for rolling back to specific positions in a
long table.
• Allows marking of transactions as names for
Savepoint Syntax: easy rollback.
SAVEPOINT < • Helps roll back only a small part of a table.
savepoint_name >; • Essentially, savepoint is a bookmark in SQL.
SQL Views
A view is a virtual table whose contents are defined by a query. Like a table, a view consists of a set of named columns
and rows of data. Unless indexed, a view does not exist as a stored set of data values in a database.
Create View
Syntax:
Example:
Example:
Join in DBMS
Join is an operation in DBMS(Database Management System) that combines the row of two or more tables based on related
It is denoted by ⋈.
columns between them.
Inner Join
Inner Join is a join operation in DBMS that combines two or more tables based on related columns and returns only rows that
have matching values among tables.
Types of Inner join
• Conditional join
• Equi Join
• Natural Join
Outer Join
Outer Join is a type of join that retrieves matching as well as non-matching records from related tables.
Types of Outer join
• Left outer join
• Right outer join
• Full outer join
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
Right Outer Join
It is also called a right join. This type of outer join retrieves all records
from the right table and retrieves matching records from the left table.
And for the record which doesn’t lies in Left table will be marked as
NULL in result Set.
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;