SlideShare a Scribd company logo
Database management concepts
• Database Management Systems (DBMS)
• An example of a database (relational)
• Database schema (e.g. relational)
• Data independence
• Architecture of a DBMS
• Types of DBMS
• Basic DBMS types
• Retrieving and manipulating data: query processing
• Database views
• Data integrity
• Client-Server architectures
• Knowledge Bases and KBS (and area of AI)
• DBMS tasks:
• Managing large quantity of structured data
• Efficient retrieval and modification: query processing and optimization
• Sharing data: multiple users use and manipulate data
• Controlling the access to data: maintaining the data integrity
• An example of a database (relational):
• Relations (tables)
• Attributes (columns)
• Tuples (rows)
• Example query: Salesperson='Mary' AND Price>100.
• Database schema (e.g. relational):
• Names and types of attributes
• Addresses
• Indexing
• Statistics
• Authorization rules to access data etc.
• Data independence: separation of the physical and logical data
• Particularly important for distributed systems
• The mapping between them is provided by the schema
• Architecture of a DBMS - three levels: external, conceptual and internal schema
• Types of DBMS
• The data structures supported: tables (relational), trees, networks, objects
• Type of service provided: high level query language, programming primitives
Basic DBMS types
• Linear files
• Sequence of records with a fixed format usually stored on a single file
• Limitation: single file
• Example query: Salesperson='Mary' AND Price>100
• Hierarchical structure
• Trees of records: one-to-many relationships
• Limitations:
• Requires duplicating records (e.g. many-to-many relationship)
• Problems when updated
• Retrieval requires knowing the structure (limited data independence):
traversing the tree from top to bottom using a procedural language
• Network structure: similar to the hierarchical database with the implementation
of many-to-many relationships
• Relational structure
• Object-Oriented structure
• Objects (collection of data items and procedures) and interactions between them.
• Is this really a new paradigm, or a special case of network structure?
• Separate implementation vs. implementation on top of a RDBMS
Relational structure
• Relations, attributes, tuples
• Primary key (unique combination of attributes for each tuple)
• Foreign keys: relationships between tuples (many-to-many).
Example: SUPPLIES defines relations between ITEM and SUPPLIER tuples.
• Advantages: many-to-many relationships, high level declarative query language (e.g. SQL)
• SQL example (retrieve all items supplied by a supplier located in Troy):
SELECT ItemName
FROM ITEM, SUPPLIES, SUPPLIER
WHERE SUPPLIER.City = "Troy" AND
SUPPLIER.Supplier# = SUPPLIES.Supplier# AND
SUPPLIES.Item# = ITEM.Item#
• Programming language interfaces: including SQL queries in the code
Retrieving and manipulating data: query processing
• Parsing and validating a query: data dictionary - a relation listing all relations and
relations listing the attributes
• Plans for computing the query: list of possible way to execute the query,
estimated cost for each. Example:
SELECT ItemNames, Price
FROM ITEM, SALES
WHERE SALES.Item# = ITEM.Item# AND Salesperson="Mary"
• Index: B-tree index, drawbacks - additional space, updating;
indexing not all relations (e.g. the keys only)
• Estimating the cost for computing a query: size of the relation, existence/size of the indices.
Example: estimating Attribute=value with a given number of tuples and the size of the index.
• Query optimization: finding the best plan (minimizing the computational cost and
the size of the intermediate results), subsets of tuples, projection and join.
• Static and dynamic optimization
Database views
• Creating user defined subsets of the database
• Improving the user interface
• Example:
CREATE VIEW MarySales(ItemName,Price)
AS SELECT ItemName, Price
FROM ITEM, SALES
WHERE ITEM.Item#=SALES.Item# AND Salesperson="Mary"
Then the query:
SELECT ItemName
FROM MarySales
WHERE Proce>100
translates to:
SELECT ItemName
FROM ITEM, SALES
WHERE ITEM.Item#=SALES.Item# AND Salesperson="Mary" AND Price>100
Data integrity
Integrity constraints: semantic conditions on the data
• Individual constraints on data items
• Uniqueness of the primary keys
• Dependencies between relations

Concurrency control
• Steps in executing a query
• Concurrent users of the database, interfering the execution of one query by another
• Transaction: a set of operations that takes the database from one consistent state to another
• Solving the concurrency control problem: making transactions atomic operations (one at a time)
• Concurrent transactions: serializability theory (two-phase locking), read lock (many), write lock (one).
• Serializible transactions: first phase - accumulating locks, second phase - releasing locks.
• Deadlocks: deadlock detection algorithms.
• Distributed execution problems:
• release a lock at one node (all locks accumulated at the other node?)
• strict two-phase locking
The Transaction Model
Primitive

Description

BEGIN_TRANSACTION

Make the start of a transaction

END_TRANSACTION

Terminate the transaction and try to commit

ABORT_TRANSACTION

Kill the transaction and restore the old values

READ

Read data from a file, a table, or otherwise

WRITE

Write data to a file, a table, or otherwise

• Examples of primitives for transactions.
The Transaction Model
BEGIN_TRANSACTION
reserve WP -> JFK;
reserve JFK -> Nairobi;
reserve Nairobi -> Malindi;
END_TRANSACTION
(a)

a)
b)

BEGIN_TRANSACTION
reserve WP -> JFK;
reserve JFK -> Nairobi;
reserve Nairobi -> Malindi full =>
ABORT_TRANSACTION
(b)

Transaction to reserve three flights commits
Transaction aborts when third flight is unavailable
Distributed Transactions

a)
b)

A nested transaction
A distributed transaction
Writeahead Log
x = 0;
y = 0;
BEGIN_TRANSACTION;
x = x + 1;
y=y+2
x = y * y;
END_TRANSACTION;
(a)

•
•

Log

Log

Log

[x = 0 / 1]

[x = 0 / 1]
[y = 0/2]

[x = 0 / 1]
[y = 0/2]
[x = 1/4]

(b)

(c)

(d)

a) A transaction
b) – d) The log before each statement is executed
Concurrency Control (1)

• General organization of managers for handling transactions.
Serializability
BEGIN_TRANSACTION
x = 0;
x = x + 1;
END_TRANSACTION
(a)

BEGIN_TRANSACTION
x = 0;
x = x + 2;
END_TRANSACTION

BEGIN_TRANSACTION
x = 0;
x = x + 3;
END_TRANSACTION

(b)

(c)

Schedule 1

x = 0; x = x + 1; x = 0; x = x + 2; x = 0; x = x + 3

Legal

Schedule 2

x = 0; x = 0; x = x + 1; x = x + 2; x = 0; x = x + 3;

Legal

Schedule 3

x = 0; x = 0; x = x + 1; x = 0; x = x + 2; x = x + 3;

Illegal

(d)

• a) – c) Three transactions T1, T2, and T3
• d) Possible schedules
Two-Phase Locking (1)

• Two-phase locking.
Two-Phase Locking (2)

• Strict two-phase locking.
Data integrity
Backup and recovery
• The problem of keeping a transaction atomic: successful or failed
What if some of the intermediate steps failed?
• Log of database activity: use the log to undo a failed transaction.
• More problems: when to write the log, failure of the recovery system executing the log .

Security and access control
• Access rules for relations or attributes. Stored in a special relation (part of the data dictionary).
• Content-independent and content-dependent access control
• Content-dependent control: access to a view only or query modification
(e.g. and-ing a predicate to the WHERE clause)
• Discretionary and mandatory access control
Knowledge Bases and KBS (and area of AI)
• Information, Data, Knowledge (data in a form that allows reasoning)
• Basic components of a KBS
• Knowledge base
• Inference (reasoning) mechanism (e.g. forward/backward chaining)
• Explanation mechanism/Interface
• Rule-based systems (medical diagnostics, credit evaluation etc.)
Dbms

More Related Content

What's hot

Real Life SQL Tuning - From 4 minutes to 8 seconds
Real Life SQL Tuning - From 4 minutes to 8 secondsReal Life SQL Tuning - From 4 minutes to 8 seconds
Real Life SQL Tuning - From 4 minutes to 8 seconds
Liron Amitzi
 
Quick overview on mongo db
Quick overview on mongo dbQuick overview on mongo db
Quick overview on mongo db
Eman Mohamed
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
Zespół Szkół nr 26
 
JAXP
JAXPJAXP
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
Terry Yoast
 
Introduction to (sql)
Introduction to (sql)Introduction to (sql)
Introduction to (sql)
Dattatray Ghorpade
 

What's hot (9)

Real Life SQL Tuning - From 4 minutes to 8 seconds
Real Life SQL Tuning - From 4 minutes to 8 secondsReal Life SQL Tuning - From 4 minutes to 8 seconds
Real Life SQL Tuning - From 4 minutes to 8 seconds
 
Xml processors
Xml processorsXml processors
Xml processors
 
Quick overview on mongo db
Quick overview on mongo dbQuick overview on mongo db
Quick overview on mongo db
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 
JAXP
JAXPJAXP
JAXP
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
Introduction to (sql)
Introduction to (sql)Introduction to (sql)
Introduction to (sql)
 
Day2 xslt x_path_xquery
Day2 xslt x_path_xqueryDay2 xslt x_path_xquery
Day2 xslt x_path_xquery
 

Viewers also liked

Transaction unit 1 topic 4
Transaction unit 1 topic 4Transaction unit 1 topic 4
Transaction unit 1 topic 4avniS
 
Distributed databases
Distributed databasesDistributed databases
Distributed databasessourabhdave
 
Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)Rushdi Shams
 
Lecture7 Transactionmanagement Concurrencycontrol
Lecture7 Transactionmanagement ConcurrencycontrolLecture7 Transactionmanagement Concurrencycontrol
Lecture7 Transactionmanagement Concurrencycontrolguest800d4
 
Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency control
balamurugan.k Kalibalamurugan
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1ahfiki
 

Viewers also liked (6)

Transaction unit 1 topic 4
Transaction unit 1 topic 4Transaction unit 1 topic 4
Transaction unit 1 topic 4
 
Distributed databases
Distributed databasesDistributed databases
Distributed databases
 
Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)Distributed Database Management Systems (Distributed DBMS)
Distributed Database Management Systems (Distributed DBMS)
 
Lecture7 Transactionmanagement Concurrencycontrol
Lecture7 Transactionmanagement ConcurrencycontrolLecture7 Transactionmanagement Concurrencycontrol
Lecture7 Transactionmanagement Concurrencycontrol
 
Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency control
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1
 

Similar to Dbms

Unit 1- dbms.ppt
Unit 1- dbms.pptUnit 1- dbms.ppt
Unit 1- dbms.ppt
minnu41
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
GeorgeSamaan9
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
KRISHNARAJ207
 
dbms (1).ppt
dbms (1).pptdbms (1).ppt
dbms (1).ppt
UbaidURRahman78
 
Top schools in noida
Top schools in noidaTop schools in noida
Top schools in noida
Edhole.com
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Altinity Ltd
 
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
Insight Technology, Inc.
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
Viet-Trung TRAN
 
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
NETWAYS
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
Fabio Fumarola
 
Database Fundamental
Database FundamentalDatabase Fundamental
Database Fundamental
Gong Haibing
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-intro
Ehtisham Ali
 
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Ontico
 
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive MetastoreOracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
DataWorks Summit
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
psathishcs
 
Real time operating systems (rtos) concepts 5
Real time operating systems (rtos) concepts 5Real time operating systems (rtos) concepts 5
Real time operating systems (rtos) concepts 5
Abu Bakr Ramadan
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
MumitAhmed1
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
SharabiNaif
 

Similar to Dbms (20)

Unit 1- dbms.ppt
Unit 1- dbms.pptUnit 1- dbms.ppt
Unit 1- dbms.ppt
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
 
dbms.ppt
dbms.pptdbms.ppt
dbms.ppt
 
dbms (1).ppt
dbms (1).pptdbms (1).ppt
dbms (1).ppt
 
Top schools in noida
Top schools in noidaTop schools in noida
Top schools in noida
 
Dbms
DbmsDbms
Dbms
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
 
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
[db tech showcase Tokyo 2017] C34: Replacing Oracle Database at DBS Bank ~Ora...
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
 
Database Fundamental
Database FundamentalDatabase Fundamental
Database Fundamental
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-intro
 
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
 
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive MetastoreOracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
 
Real time operating systems (rtos) concepts 5
Real time operating systems (rtos) concepts 5Real time operating systems (rtos) concepts 5
Real time operating systems (rtos) concepts 5
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 

More from philipsinter

Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database system
philipsinter
 
MULTIMEDIA Cocomo forum version5
MULTIMEDIA Cocomo forum version5 MULTIMEDIA Cocomo forum version5
MULTIMEDIA Cocomo forum version5 philipsinter
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentationphilipsinter
 
Final vlsi projectreport
Final vlsi projectreportFinal vlsi projectreport
Final vlsi projectreportphilipsinter
 

More from philipsinter (10)

Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database system
 
MULTIMEDIA Cocomo forum version5
MULTIMEDIA Cocomo forum version5 MULTIMEDIA Cocomo forum version5
MULTIMEDIA Cocomo forum version5
 
Multimedia
Multimedia Multimedia
Multimedia
 
multimedia 01
multimedia 01multimedia 01
multimedia 01
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
Xml
XmlXml
Xml
 
Server side
Server sideServer side
Server side
 
Java servlet
Java servletJava servlet
Java servlet
 
Lecture2
Lecture2Lecture2
Lecture2
 
Final vlsi projectreport
Final vlsi projectreportFinal vlsi projectreport
Final vlsi projectreport
 

Dbms

  • 1. Database management concepts • Database Management Systems (DBMS) • An example of a database (relational) • Database schema (e.g. relational) • Data independence • Architecture of a DBMS • Types of DBMS • Basic DBMS types • Retrieving and manipulating data: query processing • Database views • Data integrity • Client-Server architectures • Knowledge Bases and KBS (and area of AI)
  • 2. • DBMS tasks: • Managing large quantity of structured data • Efficient retrieval and modification: query processing and optimization • Sharing data: multiple users use and manipulate data • Controlling the access to data: maintaining the data integrity • An example of a database (relational): • Relations (tables) • Attributes (columns) • Tuples (rows) • Example query: Salesperson='Mary' AND Price>100.
  • 3.
  • 4. • Database schema (e.g. relational): • Names and types of attributes • Addresses • Indexing • Statistics • Authorization rules to access data etc. • Data independence: separation of the physical and logical data • Particularly important for distributed systems • The mapping between them is provided by the schema • Architecture of a DBMS - three levels: external, conceptual and internal schema • Types of DBMS • The data structures supported: tables (relational), trees, networks, objects • Type of service provided: high level query language, programming primitives
  • 5.
  • 6. Basic DBMS types • Linear files • Sequence of records with a fixed format usually stored on a single file • Limitation: single file • Example query: Salesperson='Mary' AND Price>100 • Hierarchical structure • Trees of records: one-to-many relationships • Limitations: • Requires duplicating records (e.g. many-to-many relationship) • Problems when updated • Retrieval requires knowing the structure (limited data independence): traversing the tree from top to bottom using a procedural language • Network structure: similar to the hierarchical database with the implementation of many-to-many relationships • Relational structure • Object-Oriented structure • Objects (collection of data items and procedures) and interactions between them. • Is this really a new paradigm, or a special case of network structure? • Separate implementation vs. implementation on top of a RDBMS
  • 7. Relational structure • Relations, attributes, tuples • Primary key (unique combination of attributes for each tuple) • Foreign keys: relationships between tuples (many-to-many). Example: SUPPLIES defines relations between ITEM and SUPPLIER tuples. • Advantages: many-to-many relationships, high level declarative query language (e.g. SQL) • SQL example (retrieve all items supplied by a supplier located in Troy): SELECT ItemName FROM ITEM, SUPPLIES, SUPPLIER WHERE SUPPLIER.City = "Troy" AND SUPPLIER.Supplier# = SUPPLIES.Supplier# AND SUPPLIES.Item# = ITEM.Item# • Programming language interfaces: including SQL queries in the code
  • 8. Retrieving and manipulating data: query processing • Parsing and validating a query: data dictionary - a relation listing all relations and relations listing the attributes • Plans for computing the query: list of possible way to execute the query, estimated cost for each. Example: SELECT ItemNames, Price FROM ITEM, SALES WHERE SALES.Item# = ITEM.Item# AND Salesperson="Mary" • Index: B-tree index, drawbacks - additional space, updating; indexing not all relations (e.g. the keys only) • Estimating the cost for computing a query: size of the relation, existence/size of the indices. Example: estimating Attribute=value with a given number of tuples and the size of the index. • Query optimization: finding the best plan (minimizing the computational cost and the size of the intermediate results), subsets of tuples, projection and join. • Static and dynamic optimization
  • 9. Database views • Creating user defined subsets of the database • Improving the user interface • Example: CREATE VIEW MarySales(ItemName,Price) AS SELECT ItemName, Price FROM ITEM, SALES WHERE ITEM.Item#=SALES.Item# AND Salesperson="Mary" Then the query: SELECT ItemName FROM MarySales WHERE Proce>100 translates to: SELECT ItemName FROM ITEM, SALES WHERE ITEM.Item#=SALES.Item# AND Salesperson="Mary" AND Price>100
  • 10. Data integrity Integrity constraints: semantic conditions on the data • Individual constraints on data items • Uniqueness of the primary keys • Dependencies between relations Concurrency control • Steps in executing a query • Concurrent users of the database, interfering the execution of one query by another • Transaction: a set of operations that takes the database from one consistent state to another • Solving the concurrency control problem: making transactions atomic operations (one at a time) • Concurrent transactions: serializability theory (two-phase locking), read lock (many), write lock (one). • Serializible transactions: first phase - accumulating locks, second phase - releasing locks. • Deadlocks: deadlock detection algorithms. • Distributed execution problems: • release a lock at one node (all locks accumulated at the other node?) • strict two-phase locking
  • 11. The Transaction Model Primitive Description BEGIN_TRANSACTION Make the start of a transaction END_TRANSACTION Terminate the transaction and try to commit ABORT_TRANSACTION Kill the transaction and restore the old values READ Read data from a file, a table, or otherwise WRITE Write data to a file, a table, or otherwise • Examples of primitives for transactions.
  • 12. The Transaction Model BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi; END_TRANSACTION (a) a) b) BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi full => ABORT_TRANSACTION (b) Transaction to reserve three flights commits Transaction aborts when third flight is unavailable
  • 13. Distributed Transactions a) b) A nested transaction A distributed transaction
  • 14. Writeahead Log x = 0; y = 0; BEGIN_TRANSACTION; x = x + 1; y=y+2 x = y * y; END_TRANSACTION; (a) • • Log Log Log [x = 0 / 1] [x = 0 / 1] [y = 0/2] [x = 0 / 1] [y = 0/2] [x = 1/4] (b) (c) (d) a) A transaction b) – d) The log before each statement is executed
  • 15. Concurrency Control (1) • General organization of managers for handling transactions.
  • 16. Serializability BEGIN_TRANSACTION x = 0; x = x + 1; END_TRANSACTION (a) BEGIN_TRANSACTION x = 0; x = x + 2; END_TRANSACTION BEGIN_TRANSACTION x = 0; x = x + 3; END_TRANSACTION (b) (c) Schedule 1 x = 0; x = x + 1; x = 0; x = x + 2; x = 0; x = x + 3 Legal Schedule 2 x = 0; x = 0; x = x + 1; x = x + 2; x = 0; x = x + 3; Legal Schedule 3 x = 0; x = 0; x = x + 1; x = 0; x = x + 2; x = x + 3; Illegal (d) • a) – c) Three transactions T1, T2, and T3 • d) Possible schedules
  • 17. Two-Phase Locking (1) • Two-phase locking.
  • 18. Two-Phase Locking (2) • Strict two-phase locking.
  • 19. Data integrity Backup and recovery • The problem of keeping a transaction atomic: successful or failed What if some of the intermediate steps failed? • Log of database activity: use the log to undo a failed transaction. • More problems: when to write the log, failure of the recovery system executing the log . Security and access control • Access rules for relations or attributes. Stored in a special relation (part of the data dictionary). • Content-independent and content-dependent access control • Content-dependent control: access to a view only or query modification (e.g. and-ing a predicate to the WHERE clause) • Discretionary and mandatory access control
  • 20. Knowledge Bases and KBS (and area of AI) • Information, Data, Knowledge (data in a form that allows reasoning) • Basic components of a KBS • Knowledge base • Inference (reasoning) mechanism (e.g. forward/backward chaining) • Explanation mechanism/Interface • Rule-based systems (medical diagnostics, credit evaluation etc.)