Data model

The following page provides an overview of the core tables and their schemas in Midaz, offering developers and database administrators a reference for understanding data structure and relationships. Note that future versions of Midaz may introduce additional fields or tables.


Tables


Each table is structured to support efficient querying and data integrity, aligning with Midaz's commitment to scalability and flexibility.

Table: organization

ColumnTypeDescription
iduuidThe unique identifier of the Organization.
legalNametextThe legal name of the Organization.
parentOrganizationIduuidThe unique identifier of the parent Organization.
doingBusinessAstextThe trade name of the Organization.
legalDocumenttextThe document of the Organization.
statusjsonbInformation about the status.
addressjsonbInformation about the address of the Organization.
metadatajsonbKey-value pairs to add as metadata.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzThe timestamp of soft deletion, if applicable (UTC).

Table: ledger

ColumnTypeDescription
iduuidThe unique identifier of the Ledger.
organizationIduuidThe unique identifier of the Organization.
nametextThe name of the Ledger.
statusjsonbInformation about the status.
metadatajsonbKey-value pairs to add as metadata.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: asset

ColumnTypeDescription
iduuidThe unique identifier of the Asset.
organizationIduuidThe unique identifier of the Organization.
ledgerIduuidThe unique identifier of the Ledger.
nametextThe name of the Asset.
typeenumThe type of Asset. (currency, crypto, commodity, others).
codetextThe code used to refer to the Asset.
statustextInformation about the status.
metadatajsonbKey-value pairs to add as metadata.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: portfolio

ColumnTypeDescription
iduuidThe unique identifier of the Portfolio.
organizationIduuidThe unique identifier of the Organization.
ledgerIduuidThe unique identifier of the Ledger.
entityIdtextThe unique identifier of the user responsible for the Portfolio.
nametextThe name of the Portfolio.
statusjsonbInformation about the status.
metadatajsonbKey-value pairs to add as metadata.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: segment

ColumnTypeDescription
iduuidThe unique identifier of the Segment.
organizationIduuidThe unique identifier of the Organization.
ledgerIduuidThe unique identifier of the Ledger.
nametextThe name of the Segment.
statusjsonbInformation about the status.
metadatajsonbKey-value pairs to add as metadata.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: account

ColumnTypeDescription
iduuidThe unique identifier of the Account.
organizationIduuidThe unique identifier of the Organization.
ledgerIduuidThe unique identifier of the Ledger.
assetCodetextThe code used to refer to the Asset.
nametextThe name of the Account.
aliastextA unique, user-friendly identifier for the account.
typetextThe type of account.
parentAccountIduuidThe unique identifier of the Parent Account.
entityIdtextThe unique identifier of the Entity responsible for the Account.
portfolioIduuidThe unique identifier of the Portfolio.
segmentIduuidThe unique identifier of the Segment.
statusjsonbInformation about the status.
metadatajsonbKey-value pairs to add as metadata.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: balance

ColumnTypeDescription
idtextThe unique identifier of the Balance.
organizationIduuidThe unique identifier of the Organization.
ledgerIduuidThe unique identifier of the Ledger.
accountIduuidThe unique identifier of the Account.
aliastextThe alias for the account used in the operation.
assetCodetextThe code used to refer to the Asset.
availableintegerPrevious available balance.
onHoldintegerAmount on hold/reserved.
scaleintegerThe number of decimal points used to display the balance.
versionintegerBalance version, which is updated with each transaction.
accountTypetextThe type of account.
allowSendingbooleanIf true, indicates that sending transactions is permitted.
allowReceivingbooleanIf true, indicates that receiving transactions is permitted.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: transaction

ColumnTypeDescription
iduuidThe unique identifier of the transaction.
organizationIduuidThe unique identifier of the Organization.
ledgerIduuidThe unique identifier of the Ledger.
descriptiontextDescription of the transaction.
templatetextThe unique identifier of the template if the transaction is templated.
statusjsonbInformation about the status.
amountintegerThe sent amount.
amountScaleintegerThe number of decimal points used to display the amount.
assetCodetextThe code used to refer to the Asset.
chartOfAccountsGroupNametextThe name of the group used to categorize the operations of a transaction under the same group.
sourcearrayThe list of accounts used as source.
destinationarrayThe list of accounts used as destination.
operationsarrayThe list of operations in the transaction.
metadatajsonbKey-value pairs to add as metadata.
createdAttimestamptzTimestamp of creation (UTC).
updatedAttimestamptzTimestamp of last update (UTC).
deletedAttimestamptzTimestamp of soft deletion, if applicable (UTC).


Data model


In Figure 1, you can find a visual representation of the core tables in Midaz and their relationships. The diagram helps developers and DB administrators understand how the different entities are interconnected within the system, serving as a guide for efficient data handling and integration.

Figure 1. Midaz tables and their relations.

Figure 1. Midaz tables and their relations.