Unit1 5
Unit1 5
Introduction
Overview:
o File System:
o Database System:
o Three-Schema Architecture:
o Data Independence: The ability to change the schema at one level of the
database system without affecting the schema at the next higher level. 1
o Database Languages:
o Relationships between tables are defined using primary keys and foreign keys.
ER Model Concepts:
Mapping Constraints:
Keys:
o Super Key: A set of attributes that uniquely identifies each tuple in a relation.
o Candidate Key: A minimal super key (no subset of the attributes can uniquely
identify tuples).
Generalization:
o A more general entity is called a superclass, and more specific entities are
called subclasses.
Aggregation:
Extended ER Model:
o Includes additional features like weak entities, subtypes, and
specialization/generalization hierarchies.
UNIT-02
Concepts:
Integrity Constraints:
o Entity Integrity:
o Referential Integrity:
Foreign Key: A column in one table that references the primary key of
another table.
Relational Algebra:
Difference (-): Selects rows that exist in one relation but not the other.
Cartesian Product (×): Combines all rows from one relation with all
rows from another.
Relational Calculus:
o Tuple Relational Calculus (TRC): Defines a query as a set of tuples that satisfy
a given formula.
Introduction to SQL
Characteristics:
o Declarative language: Specifies what data to retrieve, not how to retrieve it.
Advantages:
Data Types:
o Numeric (INTEGER, FLOAT, DECIMAL)
o Boolean (BOOLEAN)
o Binary (BLOB)
Literals:
Arithmetic Operators: +, -, *, /
Aggregate Functions
Joins
o LEFT JOIN: Returns all rows from the left table and matching rows from the
right table.
o RIGHT JOIN: Returns all rows from the right table and matching rows from the
left table.
Cursors
Triggers
Automatically execute a block of code in response to a database event (e.g., INSERT,
UPDATE, DELETE).
This comprehensive overview covers the essential concepts of the relational data model, SQL,
and related topics.
UNIT-03
o In simpler terms: If you know the value of X, you can uniquely determine the
value of Y.
2. Normal Forms
o Atomic Values: Each attribute contains only a single, atomic value (no lists or
repeating groups within a single cell).
o No Repeating Groups: Each row must have the same number of columns.
o In 1NF.
o In 2NF.
3. Inclusion Dependencies
Constraints that specify that a subset of tuples in one relation must also appear in
another relation.
FDs (Functional Dependencies): Used to achieve 1NF, 2NF, 3NF, and BCNF.
o Express that multiple values of one attribute are associated with a single value
of another attribute, independent of other attributes.
Object-Oriented Databases: Store data as objects with attributes and methods, better
suited for complex data structures.
NoSQL Databases: Designed to handle large volumes of unstructured or semi-
structured data (e.g., JSON, XML).
Reduce Anomalies: Prevent insertion, deletion, and update anomalies that can occur
due to redundancy.
Improve Data Maintainability: Make it easier to modify and update the database
schema.
Normalization Process
1. Identify FDs, MVDs, and JDs: Analyze the data requirements and identify the
dependencies between attributes.
2. Decompose Relations: Break down relations into smaller relations to achieve the
desired normal form.
By following these principles, database designers can create well-structured and efficient
databases that meet the specific needs of an application.
UNIT-04
UNIT-05
Concurrency Control
Definition: Mechanisms to ensure that concurrent execution of
transactions in a database system preserves data consistency and avoids
anomalies like lost updates, dirty reads, and uncommitted dependency.
Locking Techniques
Two-Phase Locking (2PL):
o Growing Phase: Transactions acquire locks before accessing data
items.
o Shrinking Phase: Transactions release locks without acquiring any
new locks.
o Strict 2PL: A transaction cannot release any lock until it commits or
aborts.
Lock Compatibility Matrix: Defines which locks can be granted
concurrently on the same data item.
Granularity of Locking:
o Fine-grained Locking: Locks are acquired on individual data items
(e.g., tuples, records).
o Coarse-grained Locking: Locks are acquired on larger units (e.g.,
tables, pages).
Timestamping Protocols
Basic Timestamp Ordering: Each transaction is assigned a unique
timestamp. Transactions are executed in timestamp order.
Thomas Write Rule: Allows a later timestamp transaction to overwrite an
earlier timestamp transaction's write if the earlier transaction has already
committed.
Validation Based Protocol
Optimistic Concurrency Control: Assumes that conflicts are rare.
Phases:
o Read Phase: Transactions read data items without acquiring locks.
o Validation Phase: Before committing, the transaction checks for
conflicts with other committed transactions.
o Write Phase: If no conflicts are detected, the transaction writes its
changes to the database.
Multiple Granularity
Hierarchical Locking: Data is organized in a hierarchy (e.g., database,
table, page, tuple).
Intention Locks: Indicate the intention to acquire locks at finer granularity
levels.
Example: A transaction may acquire an intention lock on a table before
acquiring exclusive locks on specific tuples within that table.
Multi-Version Schemes
Maintain multiple versions of data items.
Allow concurrent readers to access older versions of data while writers
create new versions.
Reduces blocking and improves concurrency.
Recovery with Concurrent Transactions
Log-Based Recovery:
o Undo/Redo Logs: Record the actions of transactions.
o Checkpointing: Periodically record the state of the system to
reduce recovery time.
Concurrency Control and Recovery:
o Concurrency control mechanisms must be coordinated with
recovery techniques to ensure consistent database state after
failures.
Case Study of Oracle
Oracle Database: A popular commercial database system that employs a
combination of concurrency control techniques, including:
o Multi-Version Concurrency Control (MVCC)
o Locking (row-level, table-level)
o Granularity Control