Video: https://www.outsystems.com/learn/courses/56/webinar-the-challenge-of-complex-offline-apps/
The requirement is usually stated in very simple terms: deliver an app that is available in all connectivity conditions. However, the solution can be anything but simple.
When data management rears its ugly head, things get really tricky fast..How are you going to synchronize that data?
Conflicts will most definitely occur and the strategy to approach them depends on how clever your implementation is.
There is no silver bullet! But we can help you think it through. If you were on hand when we showed you how to discover some of the most common sync patterns and techniques, you got a preview.
Make no mistake, though: we're going beyond the common and we're delving deep. So, if you weren’t around for Create Your Offline App, no worries - we’ll get you fully up to speed. We're not going to feed you for a day, we're here to teach you how to fish!
In this webinar you will:
- Review some of the common sync patterns OutSystems handles.
- Understand how the synchronization process happens in the background.
- Learn how to translate offline-first thinking into development best practices.
- Learn how to implement a more advanced sync scenario.
Free Online training: https://www.outsystems.com/learn/courses/
Follow us on Twitter http://www.twitter.com/OutSystemsDev
Like us on Facebook http://www.Facebook.com/OutSystemsDev
2. Technical Webinar
Sync or Swim
The Challenge of Complex Offline Apps
With Bruno Martinho from OutSystems FE & Mobile
February 14th
2PM (GMT) / 9AM (EDT) / 10PM (SGT)
5. So...
• You have decided to develop offline apps
• You are aware that things might get complicated
• You know that now is time to “Sync or Swim”
5
BE PREPARED...
8. What?
8
“Measure twice, cut once”
Data
● Define the subset of data necessary in the device
○ Scope
○ Range
● Redefine the data structure in the device
Common Pitfalls
● Don’t blindly accept: “all data must be on device”
● Don’t blindly accept: “all data must be on device”
9. When?
9
“Measure twice, cut once”
Data
● Define when data should be synched with the server
○ Device to Server
○ Server to Device
● Define the frequency of each entity
Common Pitfalls
● Trying to always sync all data, even when it is not
necessary
10. How?
10
● No Silver Bullets
● Depends on business requirements
● Five common patterns:
○ Read-only
○ Read-only (optimized)
○ Read-write, last wins
○ Read-write, conflict resolution
○ Read-write, one-to-many
Data sync is a huge challenge on offline apps:
One of the patterns;
More than one pattern;
None of these patterns.
The solution for your own use case might be:
“Measure seven times, cut once” - Russian version
16. OfflineDataSyncEvents
16
● Block that is automatically placed inside the layout
● Raise 3 events:
○ OnSyncStart - when the sync process starts
○ OnSyncComplete - when the sync process is
sucessfull
○ OnSyncError - when the sync process has an
error
17. Client Actions
17
● OfflineDataSyncConfiguration - allows to configure the
behavior of the sync process and trigger it automatically
in some occasions:
○ SyncOnOnline - Indicates if a sync process runs when the app is offline and
changes to online
○ SyncOnLogin - Indicates if a sync process runs when the login action is success
○ SyncOnResume - Indicates if a sync process runs when the user resumes the
application from background
○ RetryOnError - Indicated whether to retry in case of an error
○ RetryIntervalInSeconds - Indicates the interval to wait before the next retry
18. Client Actions
18
● OfflineDataSync - This action should have the logic to get the data from the device,
send it to the server and receive a response. With the response it may change the
local database with the server information.
● TriggerOfflineDataSync - Call this action whenever is necessary to create a manual
sync.
Common Pitfall
● When triggering manually a sync process, calling OfflineDataSync
instead of TriggerOfflineDataSync
19. Server Actions
19
● Use the server action to create the logic to sync information received from the
device in the server’s database
● The server action should be protected by checking if the user is authenticated. This
is a good practice for security reasons.
21. Five Data Sync Patterns
21
● Read-Only
● Read-Only (Optimized)
● Read-Write, Last Wins
● Read-Write, Conflict Resolution
● Read-Write, One-to-Many
Unidirectional Data Flow
Bidirectional Data Flow
22. Five Data Sync Patterns
22
To help explaining each pattern, we are now featuring some well-known “Sink or
Swim” experts (fortunately more “swim” than “sink”)
Robinson Crusoe Chuck Noland Jack Sparrow not Titanic Jack...
23. Five Data Sync Patterns
23
The OutSystems Forge has an app with a collection of offline data synchronization
patterns that we will use during this webinar
24. Read-Only Data
24
Recommended for mobile apps where end users only need to read data while the
apps are offline and the amount of data is small.
● Local database doesn’t send data to the server
● Server data is Master
● For example, a Product Catalog App
● Has an accelerator in OutSystems Service Studio:
Sync Data A
25. Read-Only Data
25
ID Name
1 Robinson Crusoe
2 Chuck Noland
ID Name
1 Robinson Crusoe
2 Chuck Noland
3 Jack Sparrow
1. Get data from server
2. Delete all data from local device
3. Write all data received from server
1 Robinson Crusoe
2 Chuck Noland
3 Jack Sparrow
28. Read-Only Data
28
1. Get data from server
2. Delete all data from local device
3. Write all data received from server
3
29. Read-Only Data (Optimized)
29
Recommended for mobile apps where end users only need to read data while the
apps are offline and the amount of data is small.
● Local database only sends timestamp to the server
● Server data is master
● Downloads less information from server
Sync Data
ALast Sync Date
Server entity data model:
● Last update date
● Soft delete field
30. Read-Only Data (optimized)
30
ID Name
1 Crusoe
2 Chuck Noland
3 Jack Sparrow
ID Name Modified Active
1 Robinson Today True
2 Chuck Noland 1 week True
3 Jack Sparrow Today False
31. Read-Only Data (optimized)
31
ID Name
1 Crusoe
2 Chuck Noland
3 Jack Sparrow
ID Name Modified Active
1 Robinson Today True
2 Chuck Noland 1 week True
3 Jack Sparrow Today False
1. Get device last sync date
Yesterday
32. Read-Only Data (optimized)
32
ID Name
1 Crusoe
2 Chuck Noland
3 Jack Sparrow
ID Name Modified Active
1 Robinson Today True
2 Chuck Noland 1 week True
3 Jack Sparrow Today False
1. Get device last sync date
Yesterday
2. Get modified and deleted in server
since last sync date UPDATED
DELETED
33. Read-Only Data (optimized)
33
ID Name
1 Robinson
2 Chuck Noland
3 Jack Sparrow
ID Name Modified Active
1 Robinson Today True
2 Chuck Noland 1 week True
3 Jack Sparrow Today False
1. Get device last sync date
Yesterday
2. Get modified and deleted in server
since last sync date UPDATED
DELETED
3. Insert or update modified in device
34. Read-Only Data (optimized)
34
ID Name
1 Robinson
2 Chuck Noland
3 Jack Sparrow
ID Name Modified Active
1 Robinson Today True
2 Chuck Noland 1 week True
3 Jack Sparrow Today False
1. Get device last sync date
Yesterday
2. Get modified and deleted in server
since last sync date UPDATED
DELETED
3. Insert or update modified in device
4. Delete in device the deleted rows in
the server
35. Read-Only Data (optimized)
35
ID Name
1 Robinson
2 Chuck Noland
3 Jack Sparrow
ID Name Modified Active
1 Robinson Today True
2 Chuck Noland 1 week True
3 Jack Sparrow Today False
1. Get device last sync date
2. Get modified and deleted in server
since last sync date UPDATED
DELETED
3. Insert or update modified in device
5. Update last sync date
Now
4. Delete in device the deleted rows in
the server
38. Read-Only Data (optimized)
38
2. Get modified and deleted in server
since last sync date
1. Get device last sync date
33. Insert or update modified in device
39. Read-Only Data (optimized)
39
2. Get modified and deleted in server
since last sync date
1. Get device last sync date
4
3. Insert or update modified in device
4. Delete in device the deleted rows in
the server
40. Read-Only Data (optimized)
40
2. Get modified and deleted in server
since last sync date
1. Get device last sync date
3. Insert or update modified in device
5. Update last sync date
5
4. Delete in device the deleted rows in
the server
41. Read-Write, Last Wins
41
Recommended for mobile apps where it is not likely for multiple end users to change
the same data while the apps are offline.
● Local database change and sends data to the server
● Data in server is always overridable
● E.g., a Field Services App
● Has an accelerator in Service Studio:
A
A
1
A1
A
A2
A => A1 => A2
42. Read-Write, Last Wins
42
ID Name
1 Crusoe
2 Chuck Noland
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
43. Read-Write, Last Wins
43
ID Name
1 Crusoe
2 Chuck Noland
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
1. Check local data for new, updated
and deleted
UPDATED
DELETE
NEW
44. Read-Write, Last Wins
44
ID Name
1 Robinson
2 Chuck Noland
3 Jack Sparrow
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
UPDATED
DELETE
NEW
45. Read-Write, Last Wins
45
ID Name
1 Robinson
3 Jack Sparrow
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
UPDATED
DELETE
NEW
3. Get all data from server
46. Read-Write, Last Wins
46
ID Name
1 Robinson
3 Jack Sparrow
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
3. Get all data from server
4. Delete all data in device
47. Read-Write, Last Wins
47
ID Name
1 Robinson
3 Jack Sparrow
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
3. Get all data from server
4. Delete all data in device
5. Write all data from server in the
device
1 Robinson True False True
3 Jack Sparrow True False True
49. Read-Write, Last Wins
49
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
2
50. Read-Write, Last Wins
50
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
3. Get all data from server
3
51. Read-Write, Last Wins
51
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
3. Get all data from server
4. Delete all data in device
4
52. Read-Write, Last Wins
52
2. On server, create, update and delete
data
1. Check local data for new, updated
and deleted
3. Get all data from server
4. Delete all data in device
5. Write all data from server in the
device
5
53. Read-Write with Conflict Detection
53
Recommended for advanced scenarios where multiple end-users will change the
same data while the apps are offline
● Local database change and sends data to the server
● Data in server has conflict and need to be resolved
● E.g Field Services App with collaboration
● New an entity in device to store conflicts
A
A
1
A1
A
A2
A => A1 ???
A2 ???
Server entity data model:
● Last update date
● Soft delete field
54. Read-Write with Conflict Detection
54
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
1. Only allow sync if no data in device is
marked as conflict
55. Read-Write with Conflict Detection
55
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
1 Month
56. Read-Write with Conflict Detection
56
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
1 Month
3. Get local device data for new, update
and delete UPDATED
DELETE
NEW
57. Read-Write with Conflict Detection
57
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
1 Month
3. Get local device data for new, update
and delete UPDATED
DELETE
NEW
4. On server, create new data
58. Read-Write with Conflict Detection
58
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
1 Month
3. Get local device data for new, update
and delete UPDATED
DELETE
NEW
4. On server, create new data
5. Update rows with modified date
before last sync. Others will be marked
as conflict
59. Read-Write with Conflict Detection
59
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
1 Month
3. Get local device data for new, update
and delete UPDATED
DELETE
NEW
4. On server, create new data
5. Update rows with modified date
before last sync. Others will be marked
as conflict
6. Delete rows with modified date
before last sync. Others will be marked
as conflict
60. Read-Write with Conflict Detection
60
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
7. Return from server last sync date and
two lists, conflicts and no-conflicts
1 Month
UPDATED
DELETE
NEW
N
ow
61. Read-Write with Conflict Detection
61
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
1 Month
UPDATED
DELETE
NEW
N
ow
ID Name
1 Crusoe
Conflict
62. 9. Delete data from local
Read-Write with Conflict Detection
62
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
1 Month
Now
N
ow
ID Name
1 Crusoe
Conflict
63. 9. Delete data from local
Read-Write with Conflict Detection
63
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
1 Month
10. Write data on the device received
from server, except for conflict. With
conflicts keep the local data
ID Name
1 Crusoe
Conflict
1 Robinson True True True
3 Jack Sparrow True False True
64. 9. Delete data from local
Read-Write with Conflict Detection
64
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
Now
10. Write data on the device received
from server, except for conflict. With
conflicts keep the local data
11. Update last sync date
ID Name
1 Crusoe
Conflict
1 Robinson True True True
3 Jack Sparrow True False True
65. 9. Delete data from local
Read-Write with Conflict Detection
65
ID Name Server Modified Active
1 Robinson True True True
2 Chuck Noland True False False
3 Jack Sparrow False True True
ID Name Modified Active
1 Crusoe Yesterday True
2 Chuck Noland 1 year True
3 Jack Sparrow Now True
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
Now
10. Write data on the device received
from server, except for conflict. With
conflicts keep the local data
11. Update last sync date
ID Name
1 Crusoe
Conflict
1 Robinson True True True
3 Jack Sparrow True False True
12. Show conflicts to solve
67. Read-Write with Conflict Detection
67
1
1. Only allow sync if no data in device is
marked as conflict
68. Read-Write with Conflict Detection
68
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
2
69. Read-Write with Conflict Detection
69
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
3. Get local device data for new, update
and delete
3
70. Read-Write with Conflict Detection
70
4
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
3. Get local device data for new, update
and delete
4. On server, create new data
71. Read-Write with Conflict Detection
71
5
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
3. Get local device data for new, update
and delete
4. On server, create new data
5. Update rows with modified date
before last sync. Others will be marked
as conflict
72. Read-Write with Conflict Detection
72
6
1. Only allow sync if no data in device is
marked as conflict
2. Get last sync date from device
3. Get local device data for new, update
and delete
4. On server, create new data
5. Update rows with modified date
before last sync. Others will be marked
as conflict
6. Delete rows with modified date
before last sync. Others will be marked
as conflict
73. Read-Write with Conflict Detection
73
7
7. Return from server last sync date and
two lists, conflicts and no-conflicts
74. Read-Write with Conflict Detection
74
8
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
75. Read-Write with Conflict Detection
75
9. Delete data from local
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
9
76. Read-Write with Conflict Detection
76
10
9. Delete data from local
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
10. Write data on the device received
from server, except for conflict. With
conflicts keep the local data
77. Read-Write with Conflict Detection
77
9. Delete data from local
7. Return from server last sync date and
two lists, conflicts and no-conflicts
8. Add the ones with conflict to the
conflict table
10. Write data on the device received
from server, except for conflict. With
conflicts keep the local data
11. Update last sync date
11
78. Read-Write, One-to-Many Data
78
Recommended for mobile apps with entities that follow a one-to-many relationship
and where it is not likely for multiple end users to change the same data while the
apps are offline.
● Local database changes and sends data with relationships to the server.
● Data in server is always overridable.
A, B
A1, B1
79. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
79
ID Name
1 Robinson Crusoe
2 Jack Sparrow
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
80. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
80
ID Name
1 Robinson Crusoe
2 Jack Sparrow
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
1. Check local data on primary table for
new, updated and deleted
NEW
81. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
81
ID Name
1 Robinson Crusoe
2 Jack Sparrow
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
NEW
NEW
82. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
82
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
3. On server, create new data NEW
NEW
83. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
83
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
3. On server, create new data
4. Create dictionary with primary Ids
NEW
NEW
Dictionary
ID NewID
2 3
84. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
84
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
3. On server, create new data
4. Create dictionary with primary Ids
5. Update rows received from device
with the new ids in the dictionary
NEW
NEW
Dictionary
ID NewID
2 3
85. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
85
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
6. Add, update and delete foreign entity
in the server
NEW
NEW
Dictionary
ID NewID
2 3
ID Name CastId
1 Wilson 3
86. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
86
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
NEW
NEW
ID Name CastId
1 Wilson 3
87. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
87
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
8. Delete the foreign entity in the
device
NEW
ID Name CastId
1 Wilson 3
88. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
88
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
8. Delete the foreign entity in the
device
9. Delete the primary entity in the
device ID Name CastId
1 Wilson 3
89. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
89
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
8. Delete the foreign entity in the
device
9. Delete the primary entity in the
device
10. Add all data for primary entity
received from the server
ID Name CastId
1 Wilson 3
1 Robinson Crusoe True False True
2 Jack Sparrow True False True
3 Chuck Noland True False True
90. ID Name Server Modified Active
1 Robinson Crusoe True False True
2 Chuck Noland False True True
3 Jack Sparrow True False True
Read-Write, One-to-Many Data
90
ID Name
1 Robinson Crusoe
2 Jack Sparrow
3 Chuck Noland
ID Name CastId Server Modified Active
1 Wilson 2 False True True
Friend
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
8. Delete the foreign entity in the
device
9. Delete the primary entity in the
device
10. Add all data for primary entity
received from the server
ID Name CastId
1 Wilson 3
1 Robinson Crusoe True False True
2 Jack Sparrow True False True
3 Chuck Noland True False True
11. Add all data for foreign entity
received from the server
1 Wilson 3 True False True
92. Read-Write, One-to-Many Data
92
2
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
93. Read-Write, One-to-Many Data
93
3
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
3. On server, create new data
94. Read-Write, One-to-Many Data
94
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
3. On server, create new data
4. Create dictionary with primary Ids
4
95. Read-Write, One-to-Many Data
95
1. Check local data on primary table for
new, updated and deleted
2. Check local data on foreign table
for new, updated and deleted
3. On server, create new data
4. Create dictionary with primary Ids
5. Update rows received from device
with the new ids in the dictionary
5
98. Read-Write, One-to-Many Data
98
8,10
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
8. Delete the foreign entity in the
device
9. Delete the primary entity in the
device
10. Add all data for primary entity
received from the server
99. Read-Write, One-to-Many Data
99
9,11
6. Add, update and delete foreign entity
in the server
7. Send both entities to the device
8. Delete the foreign entity in the
device
9. Delete the primary entity in the
device
10. Add all data for primary entity
received from the server
11. Add all data for foreign entity
received from the server
100. Summary
• Mobile Apps need offline support to deliver the best user experience.
• Design Offline-First:
○ What features or capabilities should be available offline?
○ What data do you need to store in the device database?
○ When should the data be synchronized?
○ How will you handle data in the device?
• OutSystems 10 makes building Offline Apps a walk in the park:
○ Easy offline data manipulation.
○ Out-of-the-box data synchronization patterns.
10
0