Exercise 1: The Object-Relational Impedance Mismatch — Possible Solution ========================================================================== Explanation: A relational database and an object-oriented program organise the same data in different ways. The database keeps flat tables of rows and columns, and connects them through foreign keys: a posts table has an author_id column pointing at a row in users. The program wants connected objects: a user object that holds a list of post objects. Converting between the two — writing SQL, then turning the rows that come back into objects — is work that has to be done somewhere, and the "impedance mismatch" is the name for that gap between the two models. Two concrete problems in the plain-driver example: 1. No checking of names. The SQL is just a string, and the code used `user.emial` instead of `user.email`. Nothing complains when the program is written or compiled; it only prints "undefined" when it runs — perhaps in production. 2. No types for the results. `result.rows[0]` has no known shape, so the editor can't autocomplete fields and TypeScript can't warn you if the column is renamed or the value might be missing. (A third possible answer: every query needs the same repetitive code — writing the SQL, passing parameters, and unpacking rows by hand.) WHY THIS WORKS AS AN ANSWER ------------------------------ It explains the mismatch as two different ways of shaping the same data, rather than just repeating the term, and ties each problem to a specific line of the example.