Can ChatGPT Write Better SQL Than a Data Analyst?
guest reader writes:
Extracting information from databases requires skill and knowledge of query languages like SQL (Structured Query Language).
Natural language querying (NLQ) which is also called Text-to-SQL allows formation of information retrieval questions without knowledge of database-specific languages. ChatGPT is the next level in this area.
Data analyst Marie Truong challenged ChatGPT to write better SQL in January. She is comparing valid SQL syntax, query structure, correct results, and runtime. The result? ChatGPT got 50% of it wrong.
One of many new articles about this topic tries to convert database schemas into natural language as part of chatgpt prompts to provide more precise outcomes:
There has been an expectation that ChatGPT could assist in creating database queries, just as it can assist in creating computer programs. However, creating database queries requires an understanding of the database itself, and there is no conventional way to represent database semantics.
We present a solution to this problem by developing a set of syntax that can represent database semantics, such as table structure and relationships, in natural language. This allows for the creation of semantic representations of databases that can be understood by ChatGPT and enable it to perform database management tasks.
Experiment 2:
A SQL query needs to properly join four tables: careplans, providers, patients, and encounters. The encounters table plays a critical role here as it connects the patients table with the careplans table. This information is typically contained in an Entity Relationship schema.ChatGPT has successfully generated the query that results in a correct view.
There has been a research about generating SQL queries from natural language since 2016.
Read more of this story at SoylentNews.