Chapter 3
Empress Replication Scenarios


3.1 Introduction

This chapter introduces Empress Replication by examples. The examples are given through different scenarios that an imaginary company XYZ encounters when distributing information to its divisions and branches. The purpose of each scenario is to show different situations in which Empress Replication can be used.

3.1.1 The Company XYZ

The company XYZ has its headquarters in Toronto, with its divisions in New York and Tokyo. New York division has two branches in Brooklyn and Manhattan. The hierarchical structure of the company XYZ is given in [Figure 3.1.].

Figure 3.1. XYZ company's Hierarchical Structure

The product list data is updated in headquarters in Toronto. This company used to send weekly CDs containing its complete list of products and their prices to its divisions and all the branches.

In this chapter we will see how Company XYZ can benefit from Empress Replication to distribute the product list more efficiently.

3.1.2 Format of each Scenario

Each replication scenario starts with a graphical representation. The operational assumption is that the tables of each side live in separate databases on separate hosts. A description of the scenario and its operations are given. Each separate Operation is assigned a unique number. When applicable, a hyperlink to a detail explanation of the steps of each operation is provided.

General format of the operations are:

Where:

The practical SQL commands and utility usage that can be performed for each operation are given after each command. For each scenario, a link to the script is given in [Scenario Scripts]. A brief explanation of the terms used in this chapter and throughout the rest of the manual is given in [Glossary].

The assumptions for the examples of this chapter are as follows:

3.2 Scenario A: Basic Replication

Figure 3.2. Basic Replication Scenario

3.2.1 Description

Company XYZ has decided to distribute its Product List to the branches in New York and Tokyo. In this section we describe the steps for creating a scenario to replicate the Product List in Toronto, to the branch in New York. Steps for replicating the Product List to Tokyo are the same.

3.2.2 Operations for Creating the Scenario

The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario A].

This is the simplest form of a Replication. This configuration deals with a master table TorontoPList and a replicate table NewYorkPList.

Operations OpA1, OpA2, and OpA3 can be performed to define a Master Table and start a Replication Master Server to serve this Master Table.

Operations OpA4, OpA5 and OpA6 are used to authorize table NewYorkPList as candidate RRT of TorontoPList, and to create replicate table NewYorkPList as an RRT of TorontoPList.

Operation OpA7 performs a Replication Synchronization. Operation OpA8 can be executed to check the table structure, synchronization status, and contents of RRT.

3.2.3 Other possible Operations in the Scenario

For Stopping Replication Master Server execute OpA9.

3.3 Scenario B: Cascaded Replication

The simplified graphical representation of the Cascaded Replication scenario is given in [Fig. 3.3]. The host, database and Replication Master Servers are not drawn. The structure of each RMT side and RRT side in the figure are as the one shown in [Scenario A] .

Figure 3.3. Cascaded Replication Scenario

3.3.1 Description

XYZ's division in New York will distribute the Product list to its branches in Brooklyn and Manhattan. In this case, New York division will be responsible for selecting the branches which should have the copies of the Product List. The branches that are close to New York, don't need to take their Product List information from headquarters in Toronto. The steps for creating a scenario to replicate Product List in New York to one of its branches in Brooklyn are explained. Steps for replicating the Product List to Manhattan are the same.

3.3.2 Operations for Creating the Scenario

The script of commands to set up this scenario and to later undo the effects of it are given in [Scripts: Scenario B]. The scenario shown by this configuration has one master table TorontoPList two replicate tables :
  1. NewYorkPList in Database NewYorkDB,
  2. BrooklynPList in Database BrooklynDB
This scenario deals with the table BrooklynPList as an RRT of NewYorkPList. Creating BrooklynPList as an RRT of NewYorkPList, makes NewYorkPList to be an RMT for BrooklynPList as well as being an RRT for TorontoPList. This scenario is applied to avoid bottleneck of having to synchronize from a single table in TorontoDB.

Note that in this scenario, NewYorkPList being RRT or RMT depends on the Replication Relationship which it participates in. In replication relation with TorontoPList, NewYorkPList is an RRT, and in relationship with BrooklynPList, NewYorkPList is the RMT. So there is no "absolute" RMT or RRT in Empress Replication concepts.

The operations OpB1, OpB2, OpB3, OpB4, OpB5 and OpB6 can be executed to define TorontoPList as Master Table, start a Replication Master Server to serve TorontoPList, and create NewYorkPList as its RRT.

Perform operations OpB7 and OpB8 on NewYorkHost to start a Replication Master Server NewYorkRepServer. Similar to OpB4, OpB5 and OpB6, operations OpB9, OpB10 and OpB11 are used to authorize table BrooklynPList as candidate RRT of NewYorkPList, and create Replicate Table BrooklynPList as a replicate of NewYorkPList.

3.4 Scenario C: RMT Switch (Selecting an Alternative Source of Data)

Figure 3.4. Selecting an Alternative Source of Data Scenario

3.4.1 Description

The computer in the New York division goes down occasionally, and XYZ company has decided to directly distribute the Product list to the branch in Brooklyn. So the headquarters in Toronto authorizes Brooklyn branch to get Product List from the computer located in the headquarters.

After adding Toronto as an alternative Source of data for the Brooklyn branch, the computer in Brooklyn can choose among the two sources and select the available one with the smallest Replication Master Order. Choosing a different RMT from the previous chosen RMT is called RMT Switch. The selection of the appropriate source of data is done automatically by synchronization utility. However, the administrator of Brooklyn branch can manually alter the list of candidate RMTs, to affect the automatic RMT Selection. The manual alteration of the list of candidate RMTs is described in Scenarios D and E.

3.4.2 Steps for Creating the Scenario

The script of commands to set up this scenario and to later undo the effects of it are given in [Scripts: Scenario C].

This scenario adds TorontoPList as an alternative RMT for BrooklynPList. BrooklynPList is an RRT of NewYorkPList, which is itself an RRT of TorontoPList. This scenario allows BrooklynPList to perform synchronization with TorontoPList whenever NewYorkPList is not accessible, or when the administrator of BrooklynPList wants to do so.

The relation between BrooklynPList and NewYorkPList is shown with "0". This number is indicates the Replication Master Order of NewYorkPList as RMT for BrooklynPList. This relation is created before the relation between BrooklynPList and TorontoPList, which is shown with "1". This means that synchronization of BrooklynPList is first tried to be done with NewYorkPList. If a connection between synchronization utility accessing BrooklynPList and the Replication Master Server accessing NewYorkPList can not be established, then synchronization utility will look for the RMT with a higher Replication Master Order for BrooklynPList, which is TorontoPList.

Execute the operations of Scenario B to create the same configuration. Execute OpC1 to authorize BrooklynPList to be an RRT of TorontoPList.

Execute Operation OpC2 and OpC3 to establish a new RMT for BrooklynPList. To see TorontoPList is an RMT of BrooklynPList, execute OpC4.

3.5 Scenario D: Changing Order of the RMT

Figure 3.5. Changing Order of the RMT Scenario

3.5.1 Description

The computer in the New York division goes down so frequently that company XYZ decides to choose the headquarters in Toronto as the main distributor of the Product List to the active branch in Brooklyn. Only when a connection to Toronto can not be established, shall Brooklyn branch request the Product List from New York. The selection between sources of information will be done automatically after Brooklyn branch changes the Order of its sources for replication.

3.5.2 Operations for Creating the Scenario

The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario D]. This scenario, has the same configuration as Scenario C, only that TorontoPList has a smaller order number than NewYorkPList as an RMT for BrooklynPList. So, the synchronization for BrooklynPList is first tried to connect to be done with TorontoPList. If a connection between RRT side in BrooklnHost and RMT side in TorontoHost can not be established, the synchronization utility will check for validity of NewYorkPList for performing the synchronization.

Execute the same operations as in Scenario C to have the same model.

Execute OpD1 to change the Replication Master Order for BrooklynPList.

3.6 Scenario E: Disabling RMT

Figure 3.6. Disabling RMT

3.6.1 Description

The computer in Toronto goes down so frequently that the product list in that branch is rarely up-to-date, so Brooklyn branch decides to synchronize data from New York instead. Hence, Brooklyn will disable the automatic selection of Toronto as its source of Product List.

3.6.2 Operations for Creating the Scenario

The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario E]. In this scenario, the TorontoPList is disabled from being a replication master for BrooklynPList. It means that even if the replication relation between TorontoPList and BrooklynPList exist, synchronization utility on BrooklynHost does not consider TorontoPList as an RMT for BrooklynPList when doing synchronization for BrooklynPList, regardless of the Replication Master Order of TorontoPList.

Perform the operation OpE1 to disable TorontoPList from being an RMT of BrooklynPList.

Note that RMTs are Enabled by default, and are Disabled only by executing the operation OpE1.

3.6.3 Other Possible Operations in the Scenario

Perform OpE2 to enable TorontoPList as an RMT for BrooklynPList.

3.7 Scenario F: Replication Table Switch

Figure 3.7. Replication Table Switch

3.7.1 Description

At some point in time, Company XYZ management decides to discontinue its operations at Toronto headquarters and decides to establish new headquarters in New York. The New York division (now headquarters) will be responsible for updating the Product List, and all other branches and divisions will get the updated Product List information from New York. In this scenario, a replicate table must be changed into a new Master Table. Later, a master table can be altered to a a replicate table. The switching process of replication tables to each other is called Replication Table Switch. When a Replicate Table switches to a Master Table, the updates will be made to the new Master Table, and the updated data will be propagated to other Replicate Tables in the Replication World. In a Replication world the latest replication table which switches to a Master Table, is called the Current Master Table.

3.7.2 Operation for Creating the Scenario

The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario F]. In this scenario NewYorkPList from NewYorkDB will be the new Master Table for the replication world which TorontoPList, NewYorkPList and BrooklynPList belong to. When NewYorkPList becomes a Master Table, it is not a read-only table anymore, so the users of NewYorkPList can modify the table. BrooklynPList is a Replicate of NewYorkPList and performs the synchronization with this table.

Perform operations in [Scenario B] to create the same scenario. Then perform operation OpF1 to change the table type of NewYorkPList, from REPLICATE to MASTER. This operation is usually needed when TorontoPList is not physically available, or a connection to TorontoHost can not be established from the RRT side where NewYorkPList resides.

After this operation, NewYorkPList will be the current Master Table. Any table which is already an RRT, or will become an RRT of NewYorkPList, will recognize this table as the current Master Table. Note that it is the responsibility of administrator of NewYorkPList to authorize other tables to be candidate RRT of NewYorkPList. It is also the responsibility of the authorized RRT to claim NewYorkPList as their RMT.

3.7.3 Other Possible Operations in the Scenario

Later, company XYZ might decide to reverse the decision and reestablish Toronto as headquarters.

Before changing the type of NewYorkPList to a replicate table, it is a good practice to change the original master table into an RRT of the current Master Table NewYorkPList, then synchronize it with NewYorkPList, so that TorontoPList would be up-to-date before becoming the current master table. Perform the following operations to synchronize TorontoPList with NewYorkPList.

OpF7 can be executed to change the type of NewYorkPList to a replicate table. After execution of this command, whenever NewYorkPList performs a synchronization with TorontoPList, the updates made to NewYorkPList during the time that NewYorkPList was a master table, will be reflected to TorontoPList and it will be up to date.

3.8 Scenario G: Subset Replication

Figure 3.8. Subset Replication Scenario

3.8.1 Description

Company XYZ sells movies on video tapes. It sells only limited number of tapes on Japanese market, only those done in Japanese language. That is why there is no need to distribute the whole product list to its division in Tokyo. Headquarters in Toronto will distribute only part of the table to Tokyo (tapes done in Japanese) and a part of the table to New York (tapes done in English).

3.8.2 Operations for Creating the Scenario

The script of commands to set up Subset Replication scenario are given in [Scripts: Scenario G]. In this example, a certain subset of the rows of TorontoPList are replicated to NewYorkPList, and a certain subset of the rows of TorontoPList are replicated to TokyoPList during synchronization. Subset replication, replicates rows from the master table that satisfy a predetermined condition. The subset condition is a restricted SQL Where Clause, called Subset Replication Search Condition (SRSC).

A Master Table whose subset of rows will be replicated, must have a primary key defined for it. The master table will specify the list of its attributes that will participate in selecting the rows of a subset replication. This attribute list is called Subset Attribute List (SAL). Operation OpG1. establishes a Master Table along with specifying the SAL. Perform operations OpG2. and OpG3. to start a Replication Master Server for TorontoPList.

The rows to be selected for subset replication are selected in SRSC when creating replication replicate for a master table. Execution of Operation OpG4. creates a replication replicate NewYorkPList for table TorontoPList and gives out the subset condition. Execution of Operation OpG5. creates a replication replicate TokyoPList for table TorontoPList. After these operations, perform operations OpG6, OpG7 and OpG8 and OpG9 to authorize RRT and create subset replicate tables in NewYorkDB and TokyoDB, and perform operation OpG10 and OpG11 to perform synchronization with TorontoPList.