liveBook · Manning

Structured data

As explained in Data Analysis with LLMs

Data organized according to a predefined schema, such as tables with named rows and columns or graphs with entities and relationships.

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

How Data Analysis with LLMs covers it

How deep it goes
Explains data formats and the question-to-query workflow, while deferring detailed treatment of SQL and Cypher.
Examples
Uses customer tables, social networks, and a survey-results prompt that requests SQL for questions about respondents.
What it assumes
Starts with familiar tables and graphs, and defers detailed explanations of SQL and Cypher.
What you can do after
Build it from scratch: provide a question and database structure to generate a query, then check it before execution.
How it connects
Connects structured data to relational databases, graph databases, SQL, Cypher, and natural-language query interfaces.

Also explained in

Compare how 24 books explain structured data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.