This repository has been archived on 2023-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
soft-arch/src/sa/model/decisions/0003-use-rdbms-as-databases...

39 lines
1.9 KiB
Plaintext

## ADR #0003: Use RDBMS as main choice for database technology
1. **What did you decide?**
Relational DBMSes shall be used as the main choice to store the state of the Smarthut application in each microservice.
2. **What was the context for your decision?**
An effective way to store the state of the various components of Smarthut shall be found. Namely, the DBMS shall store account details, a list of managed devices per user, and all other user-defined configurations like scenes (multi-device configurations) and automation rules (_if event `X` happens, apply scene `Y`_).
The chosen technology shall store data consistently and allow concurrent access to it, as multiple users may use Smarthut at the same time. Additionally, the chosen DBMS shall be able to maintain data consistency.
As each microservice will have its own independent data layer (i.e. DBMS instance), this ADR is not an absolute decision. However, this ADR represents the typical (or when-in-doubt) decision to be taken and proposes a general discussion on different DBMS technologies.
3. **What is the problem you are trying to solve?**
Which database paradigm shall be preferred to store data in each microservice?
4. **Which alternative options did you consider?**
- Relational DBMSes, or RDBMSes;
- Documental database (e.g. MongoDB);
- Persistent key-value storage (e.g. Redis RDB, or custom file serialization)
5. **Which one did you choose?**
- Relational DBMSes, or RDBMSes;
6. **What is the main reason for that?**
RDBMSes provide ACID properties (atomicity, consistency, isolation, and durability) and schema validation "for free".
Pros:
- Concurrent access to data;
- Schema definition and validation;
Cons:
- Distributed DBMS hard to achieve (possible fix: microservice-level
distribution and consensus can be implemented).