Structured data follows a standardized format that makes it easier for computers to process. A customer table, for example, can store one customer per row, with columns for details such as address and phone number. A graph instead stores entities and their relationships, such as people connected in a social network. section 1.2 section 5.0
The format determines which tool can analyze the data efficiently. Relational database management systems process tables, typically using SQL; graph data management systems process graphs using graph-specific query languages. A language model can turn a plain-language question into a query for the appropriate tool rather than processing a large dataset directly in its prompt. section 1.4.2 section 5.1
Ask about survey results
Suppose survey responses are stored in a database table and someone wants to compare answers from different groups. A prompt can give the language model the question, the table name, its columns, and an instruction to translate the question into SQL. The database then executes the generated query and returns the result. section 1.4.2 section 5.1
Listing 1.3 Prompt template for translating questions to SQL
Database: #1 The database contains the results of a survey, stored in a table called "SurveyResults" with the following columns: ... Question: #2 [Question] Translate the question to SQL! #3
The survey prompt template shows where to put the database description and the user's question before requesting SQL. section 1.4.2
For a new dataset, first identify its structure: table names, column headers and data types, or the entities and relationships in a graph. Include that information and the target query language in the prompt. Check generated queries rather than assuming they are accurate, and copy the database before executing them. section 5.1 section 5.5























