Database 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 ID for the Organization.
parent_organization_iduuid(Optional) If the Organization is a child, this is the unique ID of its Parent Organization.
legal_nametextThe official legal name of the Organization.
doing_business_astextThe trade or DBA name, if different from the legal name.
legal_documenttextThe registration or tax ID.
addressjsonbA structured object containing address details.
statustextThe Organization’s status (e.g., active, inactive).
status_descriptiontextA description providing context for the status.
created_attimestamptzThe timestamp when the Organization was created (UTC).
updated_attimestamptzThe timestamp of the last update (UTC).
deleted_attimestamptzThe timestamp of soft deletion, if applicable (UTC).

Table: ledger

ColumnTypeDescription
iduuidUnique ID for the Ledger.
nametextLedger name.
organization_iduuidID of the Organization that owns the Ledger.
statustextLedger status (e.g., active, closed).
status_descriptiontextExplanation of the status.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: asset

ColumnTypeDescription
iduuidUnique ID for the Asset.
nametextDescriptive name (e.g., "US Dollar").
typetextAsset category (currency, crypto, commodity, etc.).
codetextAsset code (e.g., USD, BRL).
statustextAsset status (active, inactive).
status_descriptiontextExplanation of the status.
ledger_iduuidLedger where the asset is registered.
organization_iduuidOrganization owning the asset.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: segment

ColumnTypeDescription
iduuidUnique ID for the Segment.
nametextSegment name (e.g., "Premium Customers").
ledger_iduuidLedger the segment belongs to.
organization_iduuidOrganization for this segment.
statustextSegment status (active, inactive).
status_descriptiontextExplanation of the status.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: portfolio

ColumnTypeDescription
iduuidUnique ID for the Portfolio.
nametextPortfolio name (e.g., customer label).
entity_idtextExternal reference for the owning entity/customer.
ledger_iduuidLedger containing this portfolio.
organization_iduuidOrganization that owns this portfolio.
statustextPortfolio status (active, closed, etc.).
status_descriptiontextExplanation of the status.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: account

ColumnTypeDescription
iduuidUnique ID for the Account.
nametextAccount name or nickname.
parent_account_iduuid(Optional) Parent account ID if this is a sub-account.
entity_idtextExternal reference for the account owner.
asset_codetextCode of the asset (e.g., "USD").
organization_iduuidOrganization that owns this account.
ledger_iduuidLedger containing this account.
portfolio_iduuidPortfolio grouping this account.
segment_iduuidSegment classification, if applicable.
available_balancenumericCurrent available balance.
on_hold_balancenumericAmount on hold/reserved.
balance_scalenumericDecimal precision factor.
statustextAccount status (active, frozen, etc.).
status_descriptiontextExplanation of the status.
allow_sendingbooleanWhether debits from this account are allowed.
allow_receivingbooleanWhether credits to this account are allowed.
aliastextAn alternative identifier for easier reference.
typetextAccount type (e.g., "checking", "savings").
versionnumericVersion number for concurrency control.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp of soft deletion, if applicable (UTC).

Table: transaction

ColumnTypeDescription
iduuidUnique ID for the Transaction.
parent_transaction_iduuid(Optional) Parent transaction ID, if linked.
descriptiontextBrief description or memo.
templateuuid(Optional) Template ID if the transaction is templated.
statustextTransaction status (pending, completed, reversed).
status_descriptiontextExplanation of the status.
amountnumericTotal transaction amount.
amount_scalenumericDecimal precision factor for amount.
asset_codetextAsset code (if single asset).
ledger_iduuidLedger for this transaction.
organization_iduuidOrganization that owns the transaction.
bodyjsonbJSON object storing details of the transaction.
created_attimestamptzTimestamp of creation (UTC).
updated_attimestamptzTimestamp of last update (UTC).
deleted_attimestamptzTimestamp 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.