ai-diagrams · Diagram examples · Sample fintechERD · cobranca · V1
■  Logical model · schema cobranca

schema cobranca · Invoices and receipts

The customer's invoice, billed items, collection attempts and received payments. Payments and attempts are facts: recorded once. The daily batch groups automatic attempts and the outbox carries events to the bus.

Lines

Required FK: points to exactly one row
Optional FK: points to zero or one row
crow’s footthe N side: zero or many rows per key
view only: the id points to the table, without an FK

Label to the right of the column

situacoes_contaid from a domain or reference table, without an arrow
↓ in bandthe name did not fit: the table is in the domain band
cadastro.clientesFK to a table in another schema, without an arrow
reasonFK shown without an arrow: deliberate copy, reason in label
PK FK UQprimary, foreign, unique key; id: id in a read view
- - -dashed outline: table from another schema

Header color: table type

strong entity: exists on its own; other tables reference it
dependent: only exists linked to a strong entity
associative: links two entities, many to many
process control: controls a process: run, batch, schedule
fact · immutable: something that happened; recorded once, never changes
versions · immutable: each change is a new version; the previous one remains
projection: state calculated from facts
technical: outbox (event to publish) or consumer deduplication
domain: closed list of values (status, type, cause)
configuration: rule checked by the database: allowed transitions
reference: official list loaded from an external source (currencies, countries)
read view: materialized view built from other schemas
itens_faturadependent
each item billed on the invoice
PKitem_id
FKfatura_id
descricaovarchar(140)
quantidadeinteger
valor_unitarioamount
outboxtechnical
event to publish, read by CDC
PKoutbox_id
UQevento_iduuid
agregado_iduuid
tipo_eventovarchar(80)
payloadjsonb
faturas_cobrancastrong entity
the invoice issued to the customer
PKfatura_id
UQnumerovarchar(20)
FKcliente_idcadastro.clientes
FKconta_idconta.contas
moeda_idcomum.moedas
situacao_fatura_idsituacoes_fatura
valor_totalamount
vencimentodate
emitida_emdate-time
execucoes_cobrancaprocess control
daily collection batch run
PKexecucao_id
UQdata_referenciadate
situacaovarchar(20)
iniciada_emdate-time
pagamentos_recebidosfact · immutable
each amount received; never changes
PKpagamento_recebido_id
FKfatura_id
FKconta_idconta.contas
meio_pagamento_idmeios_pagamento
UQidentificador_externovarchar(40)
valoramount
recebido_emdate-time
tentativas_cobrancafact · immutable
each attempt to collect the invoice
PKtentativa_id
FKfatura_id
FKpagamento_recebido_id
meio_pagamento_idmeios_pagamento
FKexecucao_id
numero_tentativainteger
resultadovarchar(20)
tentada_emdate-time
Domain and configuration · 2 tables · green columns store an id from one of these, without an arrow
situacoes_faturadomain
used by faturas_cobranca.situacao_fatura_id
meios_pagamentodomain
used by pagamentos_recebidos.meio_pagamento_id
· tentativas_cobranca.meio_pagamento_id
Boundary with other schemas · FK without reads: the database guarantees the row exists; the service does not read the other table

this schema points to

faturas_cobranca.cliente_id → cadastro.clientes
faturas_cobranca.conta_id → conta.contas
pagamentos_recebidos.conta_id → conta.contas

other schemas point here

none

uses from comum (shared domain and reference)

moedas
1
2
3
4
5
Relationships
1
An invoice has zero or many items; its total is their sum.
2
A payment settles an invoice; empty when unidentified and awaiting reconciliation.
3
An invoice receives zero or many collection attempts until paid or canceled.
4
The batch run groups automatic attempts; manual attempts have no run.
5
A successful attempt points to the resulting payment; empty for failed attempts.
Diagrams  ·  ERD example  ·  2026-11