Whenever you're ready, walk me through how you'd approach this.
Detail how database indexing works and when it should be applied to optimize queries.
Explain the index data structure, how the database uses it during query planning, and the trade-offs involving selectivity, writes, storage, and composite indexes. Keep the answer focused on relational databases and practical query optimization.