Advaced DB Ch1
Advaced DB Ch1
Bahman Arasteh
(Associate Prof., Software Engineering)
Department of Software Engineering,
Istinye University
E-mail: [email protected]
Overview of Databases
and
Transaction Concept
4
Advanced Database- Dr. Arasteh
Overview of Databases
5
Advanced Database- Dr. Arasteh
What is Database Systems?
• A Database Management System (DBMS) is software that enables
users to create, manage, and manipulate databases efficiently.
• It provides a systematic way to store, retrieve, update, and delete
data while ensuring security, consistency, and integrity.
• Key Functions of a DBMS:
1. Data Storage
2. Data Manipulation (Allows inserting, updating, and deleting data)
3. Data Security and Data Integrity.
4. Concurrency Control.
5. Backup & Recovery.
Columns
Rows
• Express the number of entities to which another entity can be associated via
a relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality must be one of the
following types:
– One to one
– One to many
– Many to one
– Many to many
19
Advanced Database- Dr. Arasteh
SQL Query Language
• SQL query language is nonprocedural. A query takes as input several tables
(possibly only one) and always returns a single table.
• Example to find all instructors in Comp. Sci. dept
select name
from instructor
where dept_name = 'Comp. Sci.'
• SQL is NOT a Turing machine equivalent language
• To be able to compute complex functions SQL is usually embedded in some
higher-level language
• Application programs generally access databases through one of
– Language extensions to allow embedded SQL
– Application program interface (e.g., ODBC/JDBC) which allow SQL queries
to be sent to a database
27
Advanced Database- Dr. Arasteh
Transaction Concept
• Definition:
– A transaction is a unit of program execution that accesses
and possibly updates various data items.
– A transaction comprises a unit of work performed within
a database management system.
– A transaction is a logical unit that is independently
executed for data retrieval or updates.
– A series of data manipulation statements that must either
fully complete or fully fail, leaving the database in a
consistent state.
1.read(A)
2.A := A – 50
3.write(A)
4.read(B)
5.B := B + 50
6.write(B)
1.beginTransaction;
2.accountB += 100;
3.accountA -= 100;
4.commitTransaction;
• This transaction will either transfer 100 dollar or leave both account in the
initial state.
T1 T2
1. read(A)
2. A := A – 50
3. write(A)
read(A), read(B), print(A+B)
4. read(B)
5. B := B + 50
6. write(B
• Isolation can be ensured trivially by running transactions serially
– that is, one after the other.
• However, executing multiple transactions concurrently has significant
benefits, as we will see later.