In this talk, I will introduce type systems for query languages, with a focus on SQL and GQL. Practical SQL engines exhibit subtle differences in their handling of typing constraints and implicit type casts, often overlooked in formal accounts of SQL. These variations can significantly impact the portability of queries across engines. To address this issue, we present TRAF, a formal typing semantics for SQL that explicitly captures both static and dynamic type behaviors. In addition to SQL, we turn our attention to GQL, a widely used query language for graph databases. However, executing queries on graph databases can be computationally expensive, particularly due to the extensive use of joins. To mitigate these costs, we aim to design a type system capable of identifying ‘useless’ queries. For instance, queries that are guaranteed to yield empty results or stuck.