Photon – a live demo of a natural language interface to databases
naturalsql.com
naturalsql.com
It couldn't translate that into SQL.
"What is the price in dollars of Ginger Beer?"
> SELECT Catalog_Contents.price_in_dollars FROM Catalog_Contents WHERE Catalog_Contents.price_in_dollars = "Ginger Beer"
Nope.
"What is the price in dollars of catalog entry name Ginger Beer?"
> SELECT Catalog_Contents.price_in_dollars FROM Catalog_Contents WHERE Catalog_Contents.catalog_entry_name = "Ginger Beer"
Cool! You have to be more specific than I was hoping, but this is still pretty neat.
OK - but that's not "natural language".
SELECT singer.Name FROM singer JOIN singer_in_concert ON singer.Singer_ID = singer_in_concert.Singer_ID GROUP BY singer.Singer_ID ORDER BY COUNT(*) DESC LIMIT 1
It is close... sort of? It figured out it needed to join, group, and order, but it only drew the relation to the concert, not the venue. Correctness seems a huge challenge here. Even knowing SQL, I feel I'm double checking my results at times. But I can see how this might be incredibly useful someday for Salesforce if there's confidence in the results.> SELECT COUNT(*) FROM teacher WHERE teacher.Age > "thirty"
Not a bad idea. A good idea, maybe. Implementation needs some work.
how many teachers older than 30
teachers.filter(*.age > 30).len
Same length, but the second one has a degree of precision that the first lacks. (Though they might diverge somewhat as the complexity of queries grows, I suspect programming languages would do better as they have better facilities for symbolic manipulation.) Note also that the second example (and your SQL example) had to specify the table's name, while the natural language one did not—another mark against the natural language solution. teachers.Where(t => t.Age > 30).Count(); teachers[age > 30].count
(Because I'm working on something exactly like this right now) 27 42 44 > 30
0 1 1
If all you want is a count of teachers older than 30, you can simply sum up the resulting array, so: +/0 1 1 ⍝note: '/' is reduction, so +/ is sum reduction
2
If you want the indices, you can use 'where', which will produce an array of indices corresponding to 1s in its argument, so ⍸0 1 1
1 2
Indicates that '0 1 1' has 1s at indices 1 and 2. (We could also take the length of this array to get the count of teachers older than 30, although that would be a bit silly compared to just summing the original array.)We can then use these indices to index a different array:
ages←27 42 44
names←'anthony' 'barbara' 'bert'
names[1 2]
barbara bert
names[⍸ ages>30]
barbara bert
However, we don't even need to use 'where' in this case; the reduction operator (/) has a second use which lets us say: 0 1 1 / names
barbara bert
(ages > 30) / names
barbara bert
Good luck with your database, and hope this helps!> SELECT covid_19_july_data.Deaths FROM covid_19_july_data WHERE covid_19_july_data.Confirmed = "covid"
BTW, they didn't make life easy for themselves by having a field called "number of records". I asked something like "what's the number of records" and "what's the sum of the number of records", but it kept replying with `SELECT COUNT(*) FROM wines;`.
SQL is a tight, unambiguous language, that's why it exists.
This is like a legal document written in spoken English. It's only all fine when it works.
Part of writing SQL is also understanding the underling data. This won't address this issue.
This is also not replicable. Language changes in context and time.
I guess the endgoal for this is to make non-technical people also be able to efficiently work with databases. From a purely business/financial context this would save companies hours (i.e. money) onboarding/teaching employees to use their database, and even possibly remove the need to hire expensive data analysts because their lower-tier employers suddenly can interact with their databases as efficiently as they can.
edit: I also believe you're putting the cart before the horse with your reasoning. SQL and Legal English NEED to be exact, which makes them very 'complex' because you need to disallow any edge cases. This doesn't mean we WANT them to be complex. It is way more useful if it is easy and intuitive (like natural language). Matter of fact, this would save in both Legal and SQL cases a lot of time, because in both you'd often start with natural english, like 'I want to write a rent contract that protects me and my renter from legal trouble', or 'I want to know from this database which company had the highest net profit in the last quarter'. It's only then that you put money, effort and time into translating this into Legal English or SQL.
> Please check the results in the table. Did I get it right?
yes
> Great!
list all designation
> Sorry, 'designation' is confusing to me