Understand the schema
- A table is a type of record, such as Customers, Invoices, Units, or Tenancies.
- A column is a detail on that record, such as
status,amount, orcreated_at. idis the unique identifier for one record.- A column ending in
_idusually connects to another table. For example,building_idconnects a Unit to its Building. created_atandupdated_atrecord when the record was created or last updated.nullin a result means the detail is empty or does not apply to that record.
Choose the main table
Start with the record you want one row to represent:
You can then join another table when you need related information. For example, start with
units for one row per Unit, then join buildings to show the Building name.
Amounts and times
Money columns are integers in the smallest currency unit (pence for GBP). Divide by 100 when you want pounds. For example, ask the SQL assistant: Showamount_remaining in pounds with two decimal places.
Timestamps are UTC. Scheduled queries also run in UTC. If a report is grouped by day, tell the assistant which time zone you want to use.
Tenancies and applications
An Application is the leasing pipeline. A Tenancy is the agreement created from that pipeline. Join them withtenancies.application_id = applications.id.
- Use
tenanciesfor rent roll, active agreements, start and end dates, occupancy, and when the next rent increase is due. - Use
applicationsfor conversion funnels, open pipeline steps, and Applications that have not yet produced a Tenancy. - Use
renewal_intentsfor Renewals and rent reviews that already exist. Join withrenewal_intents.source_application_id = tenancies.id.
Connect related records
Connecting tables is called a join. Common connections include:- Units to Buildings:
units.building_id = buildings.id - Invoices to Customers:
invoices.customer_id = customers.id - Invoice Items to Invoices:
invoice_items.invoice_id = invoices.id - Payments to Invoices:
payments.invoice_id = invoices.id - Subscription Items to Subscriptions:
subscription_items.subscription_id = subscriptions.id - Balance Transactions to Payouts:
balance_transactions.payout_id = payouts.id - Owner Payouts to Owners:
owner_payouts.owner_id = owners.id - Maintenance issues to Units:
maintenance_issues.unit_id = units.id - Renewal and rent-review records to Tenancies:
renewal_intents.source_application_id = tenancies.id
Every table includes account
Every table includesaccount_id. In organisation view, use it to separate records after setting Query scope.
Ask the SQL assistant to include account_id, group by account, or filter to a particular account when needed.
Tables
Portfolio
buildings— Properties in the portfolio.units— Lettable units within buildings. Status isoccupied,available, ormaintenance.tenancies— Agreements with a start date, optional end date, and normalised monthly rent. Status includespending,active,complete, andcanceled.last_rent_increase_effective_dateis the last completed rent increase; if it is empty, usedate_start. The next notice is due 10 months after that date, and the increase can take effect 12 months after it.
Leasing
applications— Pipeline records. Useopenandcurrent_step_typefor funnels.typeincludesstandardandrenewal.renewal_intents— Renewals, no-renewals, and rent reviews. Fortyperent_increase,due_atis the suggested notice date, not the date the new rent takes effect. This table only includes reviews that already exist; uselast_rent_increase_effective_dateontenanciesto find every Tenancy due a review.
Billing
customers— People and companies you bill, let to, or otherwise hold on file.invoices— Invoices issued to customers, including rent, charges, and one-off bills. Status includesdraft,open,paid,uncollectible, andvoid.invoice_items— Line items on invoices, including transfer behaviour.subscriptions— Recurring billing agreements, typically rent.subscription_items— Line items on subscriptions.payments— Collected payments. Amounts are in pence.refunds— Refunds against payments.credit_notes— Credit notes against invoices.
Finance
balance_transactions— Movements on the Yorlet balance, including fees and payouts.payouts— Payouts from the Yorlet balance to your bank account.
Owners
owners— Landlord, leaseholder, and supplier records.owner_payouts— Payouts from owner balances to owner bank accounts.
Maintenance
maintenance_issues— Repair and maintenance issues against Units, including status, category, priority, Building, Unit, reporting Customer, and assignee.