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

I'm Presentation

The document provides an overview of key concepts in Database Management Systems (DBMS), including relational algebra, transactions, SQL views, and joins. It explains various operations such as select, project, union, and different types of joins, along with transaction properties like atomicity and durability. Additionally, it covers SQL commands for committing, rolling back transactions, and managing views.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

I'm Presentation

The document provides an overview of key concepts in Database Management Systems (DBMS), including relational algebra, transactions, SQL views, and joins. It explains various operations such as select, project, union, and different types of joins, along with transaction properties like atomicity and durability. Additionally, it covers SQL commands for committing, rolling back transactions, and managing views.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DBMS

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:

Projection Operation Resu


A unary operation that returns its argument relation, with certain lt:
attributes left out.
• Notation:
∏ A1,A2,A3 ….Ak (r)
where A1, A2, …, Ak are attribute names and r is a relation name.
• Query:
Union Operation
The union operation allows us to combine two relations Resu
• Notation: r ∪ s lt:
• Query: To find all courses taught in the Fall 2009 semester, or in the Spring
2010 semester, or in both-

Set Difference Operation


The set-difference operation allows us to find tuples that are in one Quer
relation but are not in another. y:
• Notation: r – s
• Example: to find all courses taught in the Fall 2009 semester,
but not in the Spring 2010 semester-
Cartesian Product
Combines information of two different relations into one.
Notation − r Χ s

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.

When a COMMIT statement is executed in the database, it results in the following:


- All changes made by the transaction are permanently saved.
- Data modifications from the transaction become visible to other users.
- Any locks held by the transaction are released.

INSERT INTO customers (customer_id, name, email)


VALUES UPDATE customers
(1, 'John Doe', '[email protected]');
(2, 'Jane Smith', '[email protected]'); SET name = 'John Doe'
(3, 'Michael Brown', '[email protected]'); WHERE customer_id = 1;
(4, 'Emily White', '[email protected]');
COMMIT;
COMMIT;
Rolling Back a Transaction
Changes made to the database without COMMIT could be undone using the ROLLBACK command.

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.

You can add SQL statements and


functions to a view and present
the data as if the data were
coming from one single table.
A view is created with the
CREATE VIEW statement.
CREATE VIEW Syntax
A view always shows up-to-date data! The database engine recreates the view, every time a user queries it.

Create View
Syntax:

SQL CREATE VIEW Examples:


SQL Updating a View
A view can be updated with the CREATE OR REPLACE VIEW statement.
SQL CREATE OR REPLACE VIEW Syntax:

Example:

SQL Dropping a View


A view is deleted with the DROP VIEW statement.
SQL DROP VIEW Syntax:

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

Left Outer Join


It is also called left join. This type of outer join
retrieves all records from the left table and retrieves
matching records from the right table.

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;

Full Outer Join


FULL JOIN creates the result set by combining the results of both LEFT JOIN and
RIGHT JOIN. For the rows for which there is no matching, the result set will contain
NULL values.
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
Thank You
So Much

You might also like