Module 2
Module 2
➢ Reliability: The probability that a system is running (not down) at a certain time point.
➢ Availability: The probability that the system is continuously available during a time interval. (In
the context of distributed databases, it's often used as an umbrella term for both reliability and
technical availability.)
➢ Failure: A deviation of a system's behavior from that which is specified to ensure correct
execution of operations.
➢ Error: A subset of system states that causes a failure.
➢ Fault: The cause of an error.
• Reliability and availability are common potential advantages of distributed databases (DDBs).
• These concepts are directly related to faults, errors, and failures within the system.
• Fault Tolerance: Recognizes that faults will occur and designs mechanisms to detect and remove them
before they lead to system failure.
• Fault Prevention/Elimination: A more stringent approach that attempts to ensure the final system contains
no faults through exhaustive design, quality control, and extensive testing.
• A reliable Distributed Database Management System (DDBMS) tolerates failures of underlying components.
• A reliable DDBMS processes user requests as long as database consistency is not violated.
➢ Scalability: The extent to which a system can expand its capacity while continuing to operate
without interruption.
➢ Horizontal Scalability: Expanding the number of nodes in a distributed system, allowing data and
processing loads to be distributed to new nodes.2
➢ Vertical Scalability: Expanding the capacity of individual nodes in a system (e.g., increasing
storage or processing power).3
➢ Partition Tolerance: The capacity of a system to continue operating when the network connecting
its nodes is partitioned into groups, losing communication between these groups.4
➢ Network Partition: A state where the network connecting nodes in a distributed system fails,
dividing the nodes into isolated groups (partitions) where communication within a group remains,
but communication between groups is lost.5
Note:
➢ There are two types of scalability: horizontal and vertical.6
➢ Horizontal scalability involves adding more machines.7
➢ Vertical scalability involves making existing machines more powerful.8
➢ Network faults can lead to nodes being partitioned.9
➢ When a network is partitioned, nodes within a partition can still communicate,
but communication between different partitions is lost.
Autonomy
• Autonomy: The extent to which individual nodes or databases in a connected Distributed
Database (DDB) can operate independently.
• Design Autonomy: Independence of data model usage and transaction management techniques
among nodes.
• Communication Autonomy: The extent to which each node can decide on sharing information
with other nodes.
• Execution Autonomy: Independence of users to act as they please.
Essential Information:
• A high degree of autonomy is desirable in DDBs.
• High autonomy leads to increased flexibility.
• High autonomy allows for customized maintenance of individual nodes.
• Autonomy can be applied to design, communication, and execution within a DDB.
Advantages of DDB:
➢ Fragments are logical units into which a database is broken up and may be assigned for storage at the
various nodes
➢ The simplest logical units are the relations themselves i.e., each whole relation is to be stored at a
particular site
Horizontal Fragmentation (Sharding): Divides a relation horizontally by grouping rows to create subsets
of tuples, where each subset has a certain logical meaning.
Derived horizontal fragmentation: applies the partitioning of a primary relation (DEPARTMENT in our
example) to other secondary relations (EMPLOYEE and PROJECT in our example), which are related to the
primary via a foreign key. Thus, related data between the primary and the secondary relations gets
fragmented in the same way.
Vertical fragmentation: divides a relation “vertically” by columns. A vertical fragment of a relation keeps
only certain attributes of the relation.
Mixed (Hybrid) Fragmentation
• Combines both horizontal and vertical fragmentation.
• Example: An EMPLOYEE relation could be divided into six fragments using a mixed approach.
• Reconstruction: The original relation can be reconstructed using a combination of UNION and OUTER
UNION (or OUTER JOIN) operations.
• General Fragment Specification: A fragment of a relation R can be defined using a SELECT-PROJECT
combination: πL (σC (R)).
• Vertical Fragment: When C=TRUE (all tuples selected) and L/=ATTRS(R) (a subset of attributes).
• Horizontal Fragment: When C/=TRUE (a subset of tuples selected) and L=ATTRS(R) (all attributes).
• Mixed Fragment: When C/=TRUE and L/=ATTRS(R) (a subset of both tuples and attributes).
• Note: A relation itself can be considered a fragment where C=TRUE and L=ATTRS(R). The term
"fragment" can refer to a full relation or any of these types of fragments.
➢ A fragmentation schema of a database is a definition of a set of fragments that includes all attributes
and tuples in the database and satisfies the condition that the whole database can be reconstructed
from the fragments by applying some sequence of OUTER UNION (or OUTER JOIN) and UNION
operations
Data Replication and Allocation (Fig 23.2 & 23.3)
➢ An allocation schema describes the allocation of fragments to nodes (sites) of the DDBS; hence, it is a
mapping that specifies for each fragment the site(s) at which it is stored.
➢ If a fragment is stored at more than one site, it is said to be replicated.
➢Advantages:
➢ Simplicity:
• Easy to implement due to its similarity with centralized systems.
• Less complex compared to fully distributed locking methods.
Disadvantages:
➢ System Bottleneck: All lock requests go to a single site, which may become overloaded.
➢ Single Point of Failure:
• If the primary site fails, the entire system becomes non-functional.
• Reduces system reliability and availability.
Data Access Rules:
1. Read Operations:
• After getting a Read_lock from the primary site, a transaction can read from any site holding a
copy of the data item.
2. Write Operations:
• After acquiring a Write_lock, the transaction can update the data item.
• The DDBMS must update all copies of that item before releasing the lock.
2. Primary Site with Backup Site:
➢ Def: An enhancement of the Primary Site Method that includes a Backup Site to improve fault tolerance.
➢ Locking Mechanism:
• Lock Information is maintained at both the Primary and Backup sites.
• All lock requests and grants must be recorded at both sites before sending a response to the
requesting transaction.
➢ Failure Recovery:
• If the Primary Site fails:
➢ The Backup Site takes over as the new Primary Site.
➢ A new Backup Site is selected.
➢ Lock status information is copied to the new backup.
• This allows for quick recovery and continuation of processing.
Advantages:
• Improves Reliability:
Disadvantages:
➢ Locks must be recorded at both the primary and backup sites, which adds delay to lock
acquisition.
➢ Both the Primary and Backup Sites can become bottlenecks due to handling all lock
requests.
➢ System performance can still degrade under high load.
3. Primary Copy Method:
1. Def: A method where different data items have their distinguished (primary) copies stored at different sites.
2. Purpose: To distribute the load of lock coordination across multiple sites.
3. Failure Handling:
• If a site fails, only transactions that access data items with primary copies at that site are affected.
• Other transactions continue unaffected.
4. Enhancing Reliability:
• Backup sites can be used for each primary copy to improve availability and fault tolerance.
1. Primary Copy: The main copy of a data item used for coordinating locks in the distributed system.
2. Coordinator Site: The site responsible for managing lock requests and concurrency control for assigned data
items.
3. Backup Site: A secondary site that mirrors the lock information of the coordinator and can take over in case of
failure.
4. Election Process: A protocol for selecting a new coordinator when no functioning coordinator exists.
Choosing a New Coordinator Site in Case of Failure:
➢ When Used: If no backup site exists, or if both primary and backup sites are down.
➢ Election Trigger:
• A site Y detects coordinator failure by repeatedly failing to contact it.
• Site Y proposes itself as the new coordinator by sending messages to all running sites.
➢ Winning the Election: If Y receives a majority of “yes” votes, it becomes the new coordinator.
➢ Conflict Resolution: The algorithm handles simultaneous attempts by multiple sites to become the coordinator.
Distributed Concurrency Control Based on Voting
➢ Def: A fully distributed concurrency control method for replicated data, without a distinguished copy.
How It Works:
➢ Lock Requests:
• A transaction sends a lock request to all sites that have a copy of the data item.
• Each copy maintains its own lock and can independently grant or deny the request.
➢ Majority Voting:
➢ No Distinguished Copy:
• Unlike previous methods, no single site manages the lock; all sites participate equally.
➢ Truly Distributed:
• Lock coordination is shared among all sites holding a copy of the item.
Advantages:
➢ High Fault Tolerance: Works even if some sites are unavailable (as long as a majority is reachable).
➢ No single point of failure.
Disadvantages:
➢ High Message Traffic: Requires more communication between sites compared to methods using a distinguished
copy.
➢ Complexity with Failures: If site failures occur during the voting process, the algorithm becomes highly complex.
➢ Voting Method: A concurrency control method where each replica votes independently, and a transaction
proceeds only if a majority grants the lock.
➢ Majority Vote: More than half of the total number of copies must grant the lock for the transaction to proceed.
➢ Time-Out Period: The maximum time a transaction waits to collect majority votes before cancelling the request.
4. Overview of Transaction Management in Distributed Databases
Global Transaction Manager (GTM):
➢ A component introduced to coordinate distributed transactions.
➢ Temporarily assumed by the site where the transaction originated.
➢ Coordinates operations with transaction managers at multiple sites.
➢ Blocking Protocol:
• If the coordinator fails, all participants are blocked.
• Participants hold locks, leading to performance degradation.
➢ Nondeterministic outcomes can occur in the case of failures.
Phases of 3PC:
Key Concepts:
➢ Pre-commit message:
• Confirms all participants voted Yes.
• Signals that a commit is likely, but not yet finalized.
➢ Non-blocking nature: Any participant can help reach a decision if the coordinator fails.
➢ State recovery: Achieved through communication between participants.
Operating System Support for Transaction Management (Benefits):
Semaphore:
• A synchronization mechanism used to control access to shared resources by multiple processes in a
concurrent system.
• DBMSs often implement user-level semaphores, which the OS cannot manage directly.
5. Query Processing and Optimization in Distributed Databases
Distributed Query Processing: (minimizing data transfer is the main goal)
1. Query Mapping
• The user’s input query (in SQL or another language) is translated into an algebraic query on global
relations.
• This stage uses the global conceptual schema (i.e., it doesn’t yet consider where data is stored or how
it is replicated).
• Similar to centralized DBMS query translation involving normalization, semantic analysis, simplification,
and restructuring into algebraic form
2. Localization
• Converts the global algebraic query into queries on individual data fragments.
• Takes into account:
• Data fragmentation (data is split across sites)
• Replication (some fragments exist at multiple sites)
• The aim is to map global queries to local ones, knowing where the data physically resides.
3. Global Query Optimization
• Chooses the best execution strategy from a list of candidate strategies.
• Candidates are generated by:
• Reordering operations from the localized queries.
• Optimization goal: Minimize total cost, usually measured in time.
• Cost factors include:
• CPU usage
• Disk I/O
• Communication cost
• Especially important in distributed environments, where network delays (especially
in WANs)can dominate.
4. Local Query Optimization
• Performed at each site individually.
• Uses techniques similar to centralized DBMSs.
• Focuses on efficient execution of each local subquery.
Data Transfer Costs of Distributed Query Processing
Key Concepts
➢ Query Optimization: The process of determining the most efficient way to execute a query by considering
factors such as data size, location, and transfer costs.
➢ Data Transfer Cost: A crucial factor in distributed systems, referring to the amount of data that must be moved
between sites over the network during query execution.
➢ Result Site: The site where the final query output is needed.
1. Transfer both EMPLOYEE and DEPARTMENT to Site 3 1. Transfer both EMPLOYEE and DEPARTMENT to Site 3
• Total transfer = 1,000,000 + 3,500 = 1,003,500 • Total transfer = 1,000,000 + 3,500 = 1,003,500
bytes bytes
2. Transfer EMPLOYEE to Site 2, join at Site 2, send 2. Transfer EMPLOYEE to Site 2, join at Site 2, send result
result to Site 3 to Site 3
• Total transfer = 1,000,000 + 400,000 = 1,400,000 • Total transfer = 1,000,000 + 4,000 = 1,004,000
bytes bytes
3. Transfer DEPARTMENT to Site 1, join at Site 1, send 3. Transfer DEPARTMENT to Site 1, join at Site 1, send
result to Site 3 result to Site 3
• Total transfer = 3,500 + 400,000 = 403,500 bytes • Total transfer = 3,500 + 4,000 = 7,500 bytes
• Best Strategy for Q: Strategy 3 • Best Strategy for Q′: Strategy 3 (overwhelmingly
better)
What if Result Site = Site 2?
For Query Q:
Purpose: Minimize data transfer between sites by reducing relation size before transmission.
Approach: Send only the joining attribute(s) of one relation to another site, perform a semi-join, then return
only the necessary tuples and attributes.
Semi-join: A distributed query processing technique used to reduce the amount of data transferred between
sites.
Semi-join Strategy:
➢ Q:
• Transfers: 400 bytes (step 1) + 340,000 bytes (step 2) = 340,400 bytes total.
• Result: Minimal gain, since all 10,000 EMPLOYEE tuples are needed.
➢ Q′:
• Transfers: 900 bytes (step 1) + 3,900 bytes (step 2) = 4,800 bytes total.
• Result: Huge gain — only 100 EMPLOYEE tuples needed instead of 10,000.
Key Definitions:
Advantages
➢ Efficient for large datasets where only a small subset of tuples is needed for a join.
➢ Reduces communication cost in distributed systems.
Query and Update Decomposition
Key Definitions:
Catalog Stores:
➢ Insert request:
• Full tuple: <‘Alex’, ‘B’, ‘Coleman’, ‘345671239’, ‘22-APR-64’, ‘3306 Sandstone, Houston, TX’, M,33000,
‘987654321’, 4>
➢ Decomposed by DDBMS into:
• Site 1 (fragment = full EMPLOYEE): Insert full tuple.
• Site 3 (fragment = EMPD4): Insert projected tuple: <‘Alex’, ‘B’, ‘Coleman’, ‘345671239’,
33000,‘987654321’, 4>
Query Decomposition in Distributed DBMS (DDBMS)
Alternative Strategy:
➢ Send entire query Q to site 1, execute locally, then transfer final result to site 2.
a. Degree of Homogeneity
• If all servers and users use identical DBMS software, it is a homogeneous DDBMS.
• If different software systems are used across sites, it is a heterogeneous DDBMS.
b. Degree of Local Autonomy
• No local autonomy:
• Local sites cannot operate independently.
• No direct access for local transactions.
• Some local autonomy:
• Local sites can execute local transactions.
• The system permits a degree of standalone functionality.
Federated Database System (FDBS)
• Each component DBMS is autonomous and centralized.
• Some level of global view or schema is provided for application use.
• Acts as a hybrid between centralized and distributed systems.
Multi-database System
• Similar to FDBS in terms of autonomy.
• No predefined global schema.
• Applications create a temporary, interactive global view as needed.
• Still categorized under FDBS in a broader sense.
• Differences in constraints:
• Constraint specification and implementation differ across systems.
• Global schema must reconcile:
• Referential integrity constraints (from ER relationships).
• Constraints implemented via triggers in some systems.
• Potential conflicts among constraints must be managed.
• Differences in query languages:
• Variations exist even within the same data model.
• SQL has multiple versions: SQL-89, SQL-92, SQL-99, SQL:2008.
• Each version/system has different:
• Data types
• Comparison operators
• String manipulation features
Semantic Heterogeneity
• Occurs when there are differences in the meaning, interpretation, and intended use of:
• The same or
• Related data elements
• It is the biggest hurdle in designing global schemas for heterogeneous databases.
Real-World Impact
• Multinational organizations and governments face semantic heterogeneity in all domains.
• Many enterprises now rely on heterogeneous FDBSs due to:
• Historical investments (20–30 years) in independent, platform-specific databases using diverse
data models.
Middleware and Tools Used to Handle Heterogeneity
• Middleware Software
• Manages communication between global applications and local databases.
• Web-Based Application Servers
• Examples:
• WebLogic
• WebSphere
• Handle query/transaction transport and processing.
• Enterprise Resource Planning (ERP) Systems
• Examples:
• SAP
• J.D. Edwards
• May perform:
• Query distribution
• Business rule processing
• Data integration
Note: Detailed discussion of these tools is beyond the scope of the current text.
Component Database Autonomy in FDBS
FDBSs aim to maintain various types of autonomy while allowing interoperability.
1. Communication Autonomy
▪ The ability of a component database to decide whether to communicate with
another component DB.
2. Execution Autonomy
▪ Ability to:
• Execute local operations independently.
• Control the order of execution for local operations.
• Avoid interference from external operations.
3. Association Autonomy
▪ Ability to control how much functionality and data is:
• Shared with other component DBs.
• Exposed to external systems.
3. Shared-Nothing Architecture:
• Each processor has its own primary and secondary memory (no memory is shared).
• Communication happens via high-speed interconnection networks (e.g., bus or switch).
• Resembles a distributed environment, but with homogeneity and symmetry of nodes (hardware &
OS are the same).
• Used for parallel database management systems, not DDBMS.
Key Definitions:
1. Local Schema
• The full conceptual schema of a component (individual) database.
• Represents the original database structure.
2. Component Schema
• Translated version of the local schema into a canonical data
model (CDM) used by the FDBS.
• Accompanied by mappings that convert commands from CDM to
the local schema format.
3. Export Schema
• A subset of the component schema that is shared with the
federated system.
• Defines what part of the component database is visible/accessible
to the FDBS.
4. Federated Schema
• The global schema or view created by integrating all export
schemas.
• Acts as the unified interface to all shareable data across the
federation.
5. External Schema
• Defines views for specific user groups or applications, similar to
traditional external schemas.
• Tailored for particular access needs.
Figure 23.9 Five-Level Schema Architecture in FDBS
An Overview of Three-Tier Client/Server Architecture
1. Presentation Layer (Client)
➢ Role: Manages user interface; handles input, output, and navigation.
➢ Technology Used:
• Web technologies: HTML, XHTML, CSS, Flash, MathML, SVG.
• Programming/Scripting languages: Java, JavaScript, Adobe Flex, etc.
➢ Function: Displays static/dynamic web pages; sends user input to the
application layer.
➢ Communication: Uses HTTP to interact with the application layer.
3. Database Server
➢ Role: Executes queries and updates from the application layer.
➢ Technology Used: SQL for relational/object-relational databases; stored Figure 23.10
procedures. The Three-tier client/server
➢ Function: Sends query results (possibly as XML) back to the application layer. architecture.
Query Processing Flow:
Key Concepts
• Distribution Transparency: Ability of the system to hide the details of data distribution from the
application. The application can query as if the data is centralized.
• Global Concurrency Control: Techniques used to maintain consistency across replicated data
during concurrent transactions.
• Global Recovery: Mechanism to ensure atomicity of transactions, especially during site failures.
• Data Dictionary: Metadata repository containing information about data distribution and structure.
8. Distributed Catalog Management
1. A catalog in distributed databases stores metadata about data distribution, replication, fragments,
and views.
2. Effective catalog management is vital for performance, autonomy, view maintenance, distribution, and
replication.
Major Catalog Management Schemes:
1. Centralized Catalog
➢ Entire catalog resides at a single site.
➢ Easy to implement, but creates a single point of failure and slows down autonomous local
operations.
➢ Read operations from remote sites lock and unlock data at the central site; all updates must go
through it.
➢ Prone to becoming a performance bottleneck in write-heavy scenarios.
2. Fully Replicated Catalog
➢ Every site maintains a complete, identical copy.
➢ Enables fast local reads.
➢ Every update must be broadcast to all sites and coordinated via a two-phase commit to
maintain consistency.
➢ High update traffic can impact performance.
3. Partially (Partitioned) Replicated Catalog
➢ Each site stores full metadata for its local data; remote data entries may be cached.
➢ No strict freshness guarantee—cached entries may be stale until accessed or refreshed.
➢ Updates to copies are sent immediately to the originating (birth) site.
➢ Enables autonomy and supports synonyms for remote objects, aiding transparency.