Intelligent apps are emerging as the next frontier in analytics and application development. Learn how to build intelligent apps on MongoDB powered by Google Cloud with TensorFlow for machine learning and DialogFlow for artificial intelligence. Get your developers and data scientists to finally work together to build applications that understand your customer, automate their tasks, and provide knowledge and decision support.
3. Agenda
1. Database Triggers
2. RDBMS vs. Stitch Triggers
3. Evolution of computing and App architectures
4. MongoDB Stitch – Serverless Platform
5. Oplog -> Change Streams -> Stitch Triggers
6. MongoDB Swag store demo
4. Why Triggers
• Propagate changes in real
time to multiple
apps/channels
• Apps act on the changes as
they see fit
• No code changes to original
application
• Simpler development, faster
time to market, lower risk
Legacy
App
Mobile App
Web App
Microservic
e
Cloud
Service
5.
6. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular table or view in
a database. The trigger is mostly used for maintaining
the integrity of the information on the database. For example, when
a new record (representing a new worker) is added to the employees
table, new records should also be created in the tables of the taxes,
vacations and salaries. Triggers can also be used to log historical
data, for example to keep track of employees' previous salaries.
https://en.wikipedia.org/wiki/Database_trigger
7. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular table or view in
a database.
https://en.wikipedia.org/wiki/Database_trigger
8. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular table or view in
a database.
https://en.wikipedia.org/wiki/Database_trigger
9. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
https://en.wikipedia.org/wiki/Database_trigger
10. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is mostly used for maintaining the integrity of the
information on the database.
11. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is mostly used for maintaining the integrity of the
information on the database.
12. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff.
13. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff.
14. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff. For
example, when a new record (representing a new worker) is added to
the employees table, new records should also be created in the tables
of the taxes, vacations and salaries.
15. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff. For
example, when a new record (representing a new worker) is added to
the employees table, new records should also be created in the tables
of the taxes, vacations and salaries.
16. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff. For
example, when you need a database update from a legacy application
to trigger actions in a new App, or you want to add exciting new
features to an existing app.
17. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff. For
example, when you need a database update from a legacy application
to trigger actions in a new App, or you want to add exciting new
features to an existing app. Triggers can also be used to log historical
data, for example to keep track of employees' previous salaries.
18. What Are Database Triggers
A database trigger is procedural code that is automatically executed
in response to certain events on a particular collection in a database.
The trigger is partly used for maintaining the integrity of the
information on the database but also for exciting other stuff. For
example, when you need a database update from a legacy application
to trigger actions in a new App, or you want to add exciting new
features to an existing app. Triggers can also be used to log historical
data, for example to keep track of employees' previous salaries.
19. RDBMS vs. Stitch Triggers
RDBMS Triggers Stitch Triggers
Runs within/competes for
resources with the database
Runs in our Stitch infrastructure
20. RDBMS vs. Stitch Triggers
RDBMS Triggers Stitch Triggers
Runs within/competes for
resources with the database
Runs in our Stitch infrastructure
Used to impose referential Notifications, side effects,
integrating apps
21. RDBMS vs. Stitch Triggers
RDBMS Triggers Stitch Triggers
Runs within/competes for
resources with the database
Runs in our Stitch infrastructure
Used to impose referential Notifications, side effects,
integrating apps
Written in proprietary languages JavaScript (ES6)
22. RDBMS vs. Stitch Triggers
RDBMS Triggers Stitch Triggers
Runs within/competes for
resources with the database
Runs in our Stitch infrastructure
Used to impose referential Notifications, side effects,
integrating apps
Written in proprietary languages JavaScript (ES6)
Invoked before | after DB change Triggers invoked after DB
use Stitch Functions for pre-
change requirements
23. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
Evolution of Computing Models
$$$$ $$$ $$ $
24. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
Evolution of Computing Models
$$$$$ $$$$ $$$ $$ $
25. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
Evolution of Computing Models
$$$$$ $$$$ $$$ $$ $
26. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
Evolution of Computing Models
$$$$$ $$$$ $$$ $$ $
27. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
Evolution of Computing Models
$$$$$ $$$$ $$$ $$ $
28. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
Evolution of Computing Models
$$$$$ $$$$ $$$ $$ $
29. Large Data Center Virtual Machines VMs in the Cloud (EC2) Containers Serverless
Manage H/W
Complex ops
Manage less H/W
Complex ops
Size & provision VMs
Simpler ops
Size & provision containers
Simpler ops
Just send in requests
Negligible ops
Wasted resources Better utilization Rent, not buy Rent with less waste Pay as you go
$$$$$ $$$$ $$$ $$ $
Evolution of Computing Models
Evolution to more streamlined, managed
infrastructure– Cheaper to build
– Cheaper to run
– Faster time to market
31. Frontend vs. Backend (Historical)
• Frontend
• What the user interacts with
• Backend (App Server)
• Does the heavy lifting
• More secure than frontend
• Authentication
• Stores data in MongoDB
32. Migration of
functionality
Frontend vs. Backend (Historical)
• Frontend
• What the user interacts with
• Backend (App Server)
• Does the heavy lifting
• More secure than frontend
• Authentication
• Stores data in MongoDB
But this has changed over
last 10 years with Mobile
First + powerful browsers!
33. Migration to Cloud Services &
Microservices
• Backend increasingly delegates
essential but generic tasks
• Processing payments
• Authenticating users
• Posting to social media
• Nothing that makes your app unique
• Developers spend less time on
plumbing – better apps, delivered
quicker
34. Cloud Service & Microservice Integration
• Mundane, repetitive code to
integrate with cloud services &
microservices
• 41% of development time wasted here
• Data access control code
35. Developers spend even less time
on plumbing code.
Developers focus more on high-
value code that differentiates the
experience delivered by their app.
36. Streamlines app development with simple, secure access to data and services from the client with thousands of lines less
code to write and no infrastructure to manage – getting your apps to market faster while reducing operational costs.
MongoDB Stitch Serverless Platform
Services
Stitch Triggers
Real-time notifications that
launch functions in response to
changes in the database
Make further database
changes, push data to other
places, or interact with users
37. Streamlines app development with simple, secure access to data and services from the client with thousands of lines less
code to write and no infrastructure to manage – getting your apps to market faster while reducing operational costs.
Stitch QueryAnywhere Stitch Functions Stitch Mobile Sync (Beta)
MongoDB Stitch Serverless Platform
Services
Stitch Triggers
Real-time notifications that
launch functions in response
to changes in the database
Make further database
changes, push data to other
places, or interact with users
53. Oplog Format
Field Description
ts
The value for this field is a timestamp, which is a data type supported by BSON that is
ever used for replication.
h The hash field gives each entry a unique identity.
v Version of the oplog format.
op The type of operation. This will be either d (delete), u (update) or i (insert).
ns
The value of the namespace field is the name of the database followed by the name of
collection.
o2
For updates, the value for this field will be the _id of the document being updated. This
won’t exist for insertions or deletions.
o
For updates, this field contains the operation that was performed, whilst for inserts and
deletions, it will be the _id of the document that was operated on.
54. Responding to Database Changes in the Past
Before Change Streams: Oplog
}
"ts" : Timestamp(1395663575, 1),
"h" : NumberLong("-5862498903080440015"),
"v" : 2,
"op" : "i",
"ns" : ”music.songs",
"o" : {
"_id" : ObjectId("533024470d7e2c31d4443d22"),
"author" : ”David Bowie",
"title" : ”Changes"
}
}
59. What is the Swagstore
Standard Retail Store:
• Browse Items
• Add items to cart
• Checkout
• Request Notification for Restock
Additional Features:
• Update/text on item re-stock
• Shipping text/e-mail notification
Stitch Features
• Functions
• Triggers
• 3rd Party Services