Database Language Written in Natural English | Idea
The purpose of this language is to take notes in a very familiar way (as an english speaker) while simultaneously getting benefits of a database. This idea came about while playing Stardew Valley and taking notes. It's an interpretation of an idea I've been thinking about for a long time for software to help me remember what goes on in my friends' lives.
Simple Example
Some sample notes are:
- Leah doesn't like fish
- Lewis likes wild horse radish
- Sebastian might like soda
- Pierre is open 9am-9pm
- nobody likes spring onion
These would all be stored into a database. It would be nice to also have a plain-english query language:
- What does Leah like?
- When is Pierre open?
- Who likes spring onion?
Complex Example
This could get a lot more complicated, too. (whether that's good or bad, idk):
- Lewis volunteered at the Spring Festival
- Spring Festival volunteers get 10 community points
- Leah cooked stew for the Spring Festival
- Spring Festival cooks get 15 community points
Taking the simple idea from before and making it work with this more complex version is quite a jump.
Simple Schema
The simple db schema for 'Entry':
- name: leah, object: fish, verb: doesn't like (or maybe "dislike" if i want to map some synonmys together)
- name: lewis, object: wild horse radish, verb: likes
- name: leah, verb: cooked, object: stew for the Spring Festival
Complex Schema
A more complex version might further parse parts of the sentence and make additional tables. For example "stew for the spring festival" could be broken apart. Or "Lewis volunteered at the Spring Festival" could be broken apart with more intent. A really complex version might create a PERSON named Lewis, an EVENT named 'Spring Festival', and a relationship between 'PERSON' and 'EVENT' called 'volunteer'.
This would allow you to query for events, query for people, query for 'volunteers' at an a specific event, or all events.
Then for 'Spring Festival volunteers get 10 community points', the complex version would parse 'Spring Festival' as an EVENT, 'volunteers' as the relationship to 'PERSON', 'community points' as a field on 'PERSON', and add 10 to the 'community points'
How I'd actually turn any of this into a schema, I'm not sure.
Ideas for the complex schema
- a single table that is a key/value store, but there would be 3 value columns: varchar value, int value, int related_id (where int id is a relationship)
- there could be two tables: one for 'item's & one for 'value's. (and maybe a third for 'relationship's)
- Limit the use case and make a few tables, like PERSON, EVENT, and ACTION (where ACTION would be a generic entry-type thing, but could reference PERSON and EVENT)
- dynamically create complete tables using something like Redbean Php.
Additional Ideas
Use markdown headers to group things into different tables or contexts or something. For example:
# Stardew Valley
Leah likes fish
Willie loves fish
# Real Life
Reed like thai
Sam likes code
Original Notes maybe worth reviewing
for each "pride fest volunteer" (select performer from action where verb=volunteer and object=pride fest):
"get 10 community points"
action: verb=get, performer=reed, value=10 community points
item: owner=reed, name="community points", value=value+10
select from events
join people on verb="volunteer" and object="Pride Fest" where relationship = "at"
how many points does Reed have? (later we'll do a more generic example, maybe?)
first, get reed, if they were at pride fest:
select people.* from people
join events on people.id in events.volunteers
join volunteers on volunteers.event_id = events.id
AND people.id = volunteers.volunteer_id
where events.name = "Pride Fest"
AND people.name = "Reed"
Then, how is "Pride Fest volunteers get 10 community points" encoded?
- a database trigger that gets run on any new volunteer being added to pride fest, and an UPDATE statement for existing
- data in the database that can be joined on to calculate at runtime
Original Notes that are meh
These are like ... stream of thought notes I took last night which have not (and will not) be cleaned up. Probably not worth reading.
leah doesn't like fish luis likes wild horse radish
lewis birthday sunday sebastian might like soda
pierre open 9am-9pm (closed wednesday?)
nobody likes spring onion!
foss idea: a simple database programming language, just a way to track information about things. A syntax like:
Reed's Phone Number is 555 555 8154 Leah's favorite gift is not fish Reed went to dinner on march 22
then you can query: What do i know about Reed? - Their phone number is 555 555 8154 - they went to dinner on march 22
Then i could use headers to group by type
Stardew Valley
Leah's favorite gift is spaghetti
Then What do i know about Leah in Stardew Valley? If just "What do I know about Leah?" It might list all the Leah's and allow further sorting by the group
People
Reed is a blank Blob is a blab
Reed volunteered at Pride Fest Pride Fest volunteers get 10 community points
How many community points does Reed have? 10
... how? I don't think tables will work for this ... i need a key/value store ... idk
relating all this together makes it much harder
database is empty
-
Reed volunteered at Pride Fest
- create object Reed
- create new entry
- verb = volunteer
- preposition = at
- verb object = Pride Fest
- set Reed, key=volunteered, value = "at Pride Fest"
-
Reed's name is reed
- set reed.name = reed
Pride Fest volunteers get 10 community points - verb: get, it's a function ... it accepts ... a "who" and a "what" - the "who" may be separately parsed - volunteers at pride fest - pride fest volunteers - How would it know these are the same?
how many points does Reed have? (later we'll do a more generic example, maybe?)
first, get reed, if they were at pride fest:
select people.* from people
join events on people.id in events.volunteers
join volunteers on volunteers.event_id = events.id
AND people.id = volunteers.volunteer_id
where events.name = "Pride Fest"
AND people.name = "Reed"
Then, how is "Pride Fest volunteers get 10 community points" encoded?
- a database trigger that gets run on any new volunteer being added to pride fest, and an UPDATE statement for existing
- data in the database that can be joined on to calculate at runtime
pride fest is an object it references "volunteers" "volunteers" expands into "people who volunteered at [Pride Fest]" "get" is a verb --- there's a new THING that was done with / done to a "people" - what do you do to "people"? Add 10 to their "community points" (simple key/value pair)
so "volunteers" actually refers to select * from people join events, join actions where action.name="volunteer", action.performer="Reed", action.object="Pride Fest" (sad pseudo-query)
paraphrase: get 1 'people' where the 'people' had a 'volunteer' action 'at pride fest'
perhaps 'at pride fest' should be broken down?
so how is "people who volunteered at Pride Fest" stored?
person: name reed -- though, so far, I really only need the 'action' action: verb volunteer, performer reed, object pride fest
So how could "Pride Fest volunteers get 10 community points" be stored?
for each "pride fest volunteer" (select performer from action where verb=volunteer and object=pride fest): "get 10 community points" action: verb=get, performer=reed, value=10 community points item: owner=reed, name="community points", value=value+10
how does "10 community points" get parsed?
- item: name = "community points" value = 10
-- idk
select from events join people on verb="volunteer" and object="Pride Fest" where relationship = "at"
people join