SQL Unit 3 Distributed DB
SQL Unit 3 Distributed DB
Note: Heterogenous DDMS have local users while Homogenous DDMS does not have
local users
STRUCTURE OF DISTRIBUTED DATABASE
A Distributed Database System is a kind of database that is present or divided in more
than one location, which means it is not limited to any single computer system. It is
divided over the network of various systems. The Distributed Database System is
physically present on the different systems in different locations. This can be
necessary when different users from all over the world need to access a specific
database
Parameters of Distributed Database Systems:
• Distribution: It describes how data is physically distributed among the several
sites.
• Autonomy: It reveals the division of power inside the Database System and the
degree of autonomy enjoyed by each individual DBMS.
• Heterogeneity: It speaks of the similarity or differences between the databases,
system parts, and data models.
Common Architecture Models of Distributed Database Systems:
• Client-Server Architecture of DDBMS:
This architecture is two level architecture where clients and servers are the points or
levels where the main functionality is divided. There is various functionality provided
by the server, like managing the transaction, managing the data, processing the
queries, and optimization.
Note: DB-1 replicates on different sites, creating copies of the same data.
Fragmentation
In Fragmentation, the relations are fragmented, which means they are split into smaller
parts. Each of the fragments is stored on a different site, where it is required. In this,
the data is not replicated, and no copies are created. Consistency of data is highly
benefitted from Fragmentation.
The prerequisite for fragmentation is to make sure that the fragments can later be
reconstructed into the original relation without losing any data.
Consistency is not a problem here as each site has a different piece of information.
There are two types of fragmentation,
Horizontal Fragmentation – Splitting by rows.
Vertical fragmentation – Splitting by columns.
Horizontal Fragmentation(or Sharding)
The relation schema is fragmented into group of rows, and each group is then
assigned to one fragment.
Vertical Fragmentation
The relation schema is fragmented into group of columns, called smaller schemas.
These smaller schemas are then assigned to each fragment.
Each fragment must contain a common candidate key to guarantee a lossless join.
In the given scenario, if two users simultaneously try to book the only available seat
on a train, the transaction is considered incomplete. According to atomicity, the first
user who successfully clicks the booking button will reserve the seat and receive a
notification, while the second user's transaction will be rolled back, and they will be
notified that no more seats are available.
In a simpler example, if a person tries to book a ticket, selects a seat, and proceeds
to the payment gateway but encounters a failure due to bank server issues, their
booked seat will not be reserved for them. A complete transaction involves reserving
the seat and completing the payment. If any step fails, the operation is aborted, and
the user is brought back to the initial state without their seat being reserved.
2. Consistency in DBMS
This ACID Property will verify the total sum of seats left in the train + sum of seats
booked by users = total the number of seats present in the train. After each transaction,
consistency is checked to ensure nothing has gone wrong.
Example Let us consider an example where one person is trying to book a ticket. They
are able to reserve their seat but their payment hasn’t gone through due to bank
issues. In this case, their transaction is rolled back. But just doing that isn’t sufficient.
The number of available seats must also be updated. Otherwise, if it isn’t updated,
there will be an inconsistency where the seat given up by the person is not accounted
for. Hence, the total sum of seats left in the train + the sum of seats booked by users
would not be equal to the total number of seats present in the train if not for
consistency.
3. Isolation in DBMS
Isolation is defined as a state of separation. Isolation is an ACID Property in DBMS
where no data from one database should impact the other and where many
transactions can take place at the same time. In other words, when the operation on
the first state of the database is finished, the process on the second state of the
database should begin. It indicates that if two actions are conducted on two different
databases, the value of one database may not be affected by the value of the other.
When two or more transactions occur at the same time in the case of transactions,
consistency should be maintained. Any modifications made in one transaction will not
be visible to other transactions until the change is committed to the memory.
Example Suppose two people try to book the same seat simultaneously. Transactions
are serialized to maintain data consistency. The first person's transaction succeeds,
and they receive a ticket. The second person's transaction fails as the seat is already
booked. They receive an error message indicating no available seats.
4. Durability in DBMS
The ACID Property durability in DBMS refers to the fact that if an operation is
completed successfully, the database remains permanent in the disk. The database’s
durability should be such that even if the system fails or crashes, the database will
survive. However, if the database is lost, the recovery manager is responsible for
guaranteeing the database’s long-term viability. Every time we make a change, we
must use the COMMIT command to commit the values.
Example Suppose that there is a system failure in the railway management system
resulted in the loss of all booked train details. Millions of users who had paid for their
seats are now unable to board the train, causing significant financial losses and
eroding trust in the company. The situation is particularly critical as these trains are
needed for important reasons, causing widespread panic and inconvenience.