Visits and Transactions tables on user_id and visit_date = transaction_date to include all visits, even those without transactions.user_id and visit_date, and count the number of transactions for each group to get the transactions_count.transactions_count and count the number of visits for each transaction count to get the visits_count.transactions_count observed.visits_count with 0, as these represent transaction counts with no visits.transactions_count.erDiagram
Visits {
int user_id
date visit_date
}
Transactions {
int user_id
date transaction_date
int amount
}
Visits ||--o{ Transactions : ""