Create Partial Replicas

   

What Are Partial Replicas?

Partial replicas are replicas that contain only a subset of records in a full replica. To create a partial replica, you specify a filter that restricts the data that's synchronized to a subset of the full database. By using partial replicas, you can synchronize a replica with only the data that you need, rather than with an entire database.

For example, a business might store its entire sales database at the headquarters office but replicate only regional data to its regional offices across the country/region. You can create a separate replica for each regional office that contains only the data relating to that region. The database at the headquarters office would be a full replica, with which each partial replica would be synchronized.

Advantages of Using Partial Replicas

Partial replicas can make your database effectively smaller, since you need only replicate the portions that you work with frequently. Synchronizing a partial replica takes less time, and the replica itself requires less disk space.

Partial replicas can help restrict access to data. In the case of a sales database, partial replicas can help ensure that people in a regional sales office won't view sales data for other regional offices. Although you can use partial replicas to restrict access to records, they aren't a substitute for a security system.

Partial replicas also have benefits for replicating data over local area networks (LANs) and wide area networks (WANs). By restricting which data is replicated, partial replicas can reduce the amount of data transferred over a LAN or a long-distance carrier. This can reduce network traffic and lower telecommunications costs.

Creating a Partial Replica with ActiveX Data Objects (ADO) Using the Jet & Replication Objects 2.5 Library (msjro.dll)

To create a partial replica, follow these steps:

  1. Use the CreateReplica method on a Replica object, specifying the jrRepTypePartial constant in the replicatype argument. This creates the partial replica.
  2. Use the Filters property to set the desired filters and relationships that determine which data to replicate from the full replica.
  3. Use the PopulatePartial method to transfer all records from the full replica that meet the new replica filter criteria.

When you change data or the filter criteria in the partial replica, you should use the Synchronize and PopulatePartial methods together to ensure that all data is propagated to the full replica and that the partial replica is repopulated based on the current filter criteria.

Note   Once you create a partial replica, you can't convert it to a full replica. If you remove all of the replica filters and replica relations within the partial replica, it will contain all the records of a full replica, but it will still have the same limitations and restrictions of a partial replica.

Creating a Partial Replica with Data Access Objects (DAO)

To create a partial replica, follow these steps:

  1. Use the MakeReplica method on a Database object, specifying the dbRepMakePartial constant in the options argument. This creates the partial replica.
  2. Use the ReplicaFilter and PartialReplica properties to set the desired filters and relationships that determine which data to replicate from the full replica.
  3. Use the PopulatePartial method to transfer all records from the full replica that meet the new replica filter criteria.

When you change data or the filter criteria in the partial replica, you should use the Synchronize and PopulatePartial methods together to ensure that all data is propagated to the full replica and that the partial replica is repopulated based on the current filter criteria.

Note   Once you create a partial replica, you can't convert it to a full replica. If you remove all of the replica filters and replica relations within the partial replica, it will contain all the records of a full replica, but it will still have the same limitations and restrictions of a partial replica.

Partial Replicas and Referential Integrity

In a replica that has relationships that enforce referential integrity, many of the tables in the database may be related to the table on which your filter is based. When you create a partial replica, you need to make certain that you include any tables that are related to the table containing the data you want.

For example, if you're using the Northwind sample database, you might place a filter on an Employees table, such as [EmployeeID]=1, that synchronizes only one employee's records. Because the Employees table is in a relationship with the Orders and Order Details tables, you must also include those tables so that your partial replica includes the corresponding records for that employee in the Orders and Order Details tables.

You may need to include other tables that are only indirectly related to your filter. For example, you may want your partial replica to include a list of all products so that new orders can include any products that are available. In this case, you must include the Products table in your partial replica.

You should also be aware of tables in your database that have no enforced relationships, such as lookup tables, or tables with relationships where referential integrity isn't enforced. For example, a table that populates a combo box might not take part in any relationships. If you choose to include such a table, all records will be retrieved; otherwise no records will be retrieved.