A Data Store is a BPMN construct that represents a storage location where data is stored, retrieved, and can be accessed among multiple process instances, including different process models.
It can represent a database, a file system, or any other storage mechanism.
You might use a Data Store when it is not sufficient for data to be accessible in just a single process instance, but it needs to be shared across different process instances.
If you have a use case where you need to store data and access it from multiple different process instances, you could also consider using a Service Task to contact a database external to SpiffWorkflow, either via a database library in a connector or using a database via an API.
Key-Key-Value (KKV) Data Stores extend the traditional key-value model by introducing an additional key layer.
This structure enables more complex and hierarchical data storage solutions, making them particularly suited for BPMN (Business Process Model and Notation) processes that manage multifaceted data relationships.
- **Use Cases**: Ideal for scenarios requiring rich, structured data access within workflows, such as managing inventories, categorizing user profiles, or handling complex hierarchical data like the provided movies example.
Integrating KKV data stores within BPMN diagrams involves modeling tasks that interact with the data store for CRUD (Create, Read, Update, Delete) operations.
Here's how to depict such interactions using a BPMN example focused on movie data management:
### BPMN Example: Movie Data Management
#### Process Overview
![KKV data_store](images/DataStore_KKV.png)
1.**Start Event**: Initiates the movie data management workflow.
2.**Script Task: Populate Data Store**
- Uses a script to populate the "Movies" data store with detailed information about characters in various movies, demonstrating the KKV structure (Director -> Movie -> Character Attributes).
3.**Script Task: Extract Single Record**
- Retrieves specific movie details from the "Movies" data store.
- **Data Store Reference**: Each script task interacts with a "Movies" data store, specified in the task's properties.
The data store's KKV nature is indicated, allowing for structured data access and manipulation.
- **Selection of Data Source**: In the properties section of the tasks, the "Movies" data store is selected as the data source, highlighting how BPMN tasks can be explicitly linked to specific data stores for operations.
In BPMN (Business Process Model and Notation), incorporating a JSON file as a data store offers a versatile method for managing structured data throughout a process.
Before detailing the process flow, it's crucial to introduce the JSON data store structure used in this example:
```
[
{
"name": "Glacier Freeze",
"color": "#C0C0C0",
"description": "Icy, refreshing citrus flavor"
},
{
"name": "Fierce Grape",
"color": "#AA77CC",
"description": "Bold and intense grape flavor"
},
...
{
"name": "X-Fruit Fusion",
"color": "#D0DBFF",
"description": "Mystery blend of multiple fruit flavors"
}
]
```
This JSON array contains various Gatorade flavors, each with attributes for `name`, `color`, and `description`, serving as the data store for the BPMN process.
#### BPMN Example: Gatorade Flavors
![JSON data_store](images/JSON_data_store.png)
1.**Start Event**: Triggers the workflow for Gatorade flavor selection.