What are the key considerations when designing a database schema for a new application?
Treat this as a PostgreSQL schema-design exercise. Using the supplied relational tables, write a query that summarizes relationship coverage for every user, including users without applications or events.
Output
- One row per user with
user_id, email, application_count, and latest_event_at
- Include users with no related records, displaying zero or NULL where appropriate
- Order by
user_id ascending
Output details
- Count each application only once, even when it has multiple events.
- Return
application_count as 0 for users without applications.
- Leave
latest_event_at as NULL when no related events exist.