Database Schema

Reference documentation for the dscr.ai database tables and relationships.

This page documents the core database tables, their columns, and relationships. The schema is managed through Supabase migrations.

Core Tables

The primary tables include deals, borrowers, entities, documents, applications, loans, and scenarios. Each table includes standard audit columns (created_at, updated_at) and organization scoping via org_id.

deals

ColumnTypeRequiredDescription
iduuidYesPrimary key
organization_iduuidYesFK → organizations
property_addresstextYesProperty street address
loan_amountnumericRequested loan amount
stagetextYesCurrent pipeline stage
statustextYesDeal status (active, closed, archived)
created_attimestamptzYesRow creation timestamp
updated_attimestamptzYesLast-modified timestamp

borrowers

ColumnTypeRequiredDescription
iduuidYesPrimary key
organization_iduuidYesFK → organizations
first_nametextYesBorrower first name
last_nametextYesBorrower last name
emailtextContact email
phonetextContact phone
created_attimestamptzYesRow creation timestamp
updated_attimestamptzYesLast-modified timestamp

entities

ColumnTypeRequiredDescription
iduuidYesPrimary key
organization_iduuidYesFK → organizations
nametextYesEntity legal name
entity_typetextYesLLC, Corporation, Trust, etc.
state_of_formationtextUS state of formation
eintextEmployer Identification Number
created_attimestamptzYesRow creation timestamp
updated_attimestamptzYesLast-modified timestamp

applications

ColumnTypeRequiredDescription
iduuidYesPrimary key
deal_iduuidYesFK → deals
borrower_iduuidYesFK → borrowers
entity_iduuidFK → entities (optional)
roletextYesBorrower role in the deal
created_attimestamptzYesRow creation timestamp

Entity Relationships

FromToTypeVia
organizationsdealsone-to-manydeals.organization_id
dealsapplicationsone-to-manyapplications.deal_id
dealsborrowersmany-to-manyapplications
dealsentitiesmany-to-manyapplications
borrowerscredit_reportsone-to-manycredit_reports.borrower_id

Enums

entity_type

llc, corporation, trust, partnership, individual

us_states

All 50 US states plus DC, as two-letter abbreviations.

Security

All tables with tenant data have RLS policies enforcing organization isolation. See Row-Level Security for details.