<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bri Holt</title>
    <description>The latest articles on DEV Community by Bri Holt (@briholt).</description>
    <link>https://dev.to/briholt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3181854%2F4ea44442-d6a0-4314-878b-4ff5c218acec.JPEG</url>
      <title>DEV Community: Bri Holt</title>
      <link>https://dev.to/briholt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/briholt"/>
    <language>en</language>
    <item>
      <title>Memelang: Hybrid graph-relational query language for RAG</title>
      <dc:creator>Bri Holt</dc:creator>
      <pubDate>Mon, 19 May 2025 21:43:42 +0000</pubDate>
      <link>https://dev.to/briholt/memelang-hybrid-graph-query-language-for-rag-i81</link>
      <guid>https://dev.to/briholt/memelang-hybrid-graph-query-language-for-rag-i81</guid>
      <description>&lt;h1&gt;
  
  
  Memelang v5
&lt;/h1&gt;

&lt;p&gt;Memelang is a concise query language for structured data, knowledge graphs, retrieval-augmented generation, and semantic data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Memes
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;&lt;em&gt;meme&lt;/em&gt;&lt;/strong&gt; comprises key-value pairs separated by spaces and is analogous to a relational database row.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m=123 R1=A1 R2=A2 R3=A3;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;M-identifier&lt;/em&gt;&lt;/strong&gt;: an arbitrary integer in the form &lt;code&gt;m=123&lt;/code&gt;, analogous to a primary key&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;R-relation&lt;/em&gt;&lt;/strong&gt;: an alphanumeric key analogous to a database column&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;A-value&lt;/em&gt;&lt;/strong&gt;: an integer, decimal, or string analogous to a database cell value&lt;/li&gt;
&lt;li&gt;Non-alphanumeric A-values are CSV-style double-quoted &lt;code&gt;="John ""Jack"" Kennedy"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Memes are ended with a semicolon&lt;/li&gt;
&lt;li&gt;Comments are prefixed with double forward slashes &lt;code&gt;//&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Example memes for the Star Wars cast
m=123 actor="Mark Hamill" role="Luke Skywalker" movie="Star Wars" rating=4.5;
m=456 actor="Harrison Ford" role="Han Solo" movie="Star Wars" rating=4.6;
m=789 actor="Carrie Fisher" role=Leia movie="Star Wars" rating=4.2;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Queries
&lt;/h3&gt;

&lt;p&gt;Queries are partial memes with empty parts as wildcards:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Empty A-values retrieve all values for the specified R-relation&lt;/li&gt;
&lt;li&gt;Empty R-relations retrieve all relations for the specified A-value&lt;/li&gt;
&lt;li&gt;Empty R-relations and A-values (&lt;code&gt;=&lt;/code&gt;) retrieve all pairs in the meme
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Query for all movies with Mark Hamill as an actor
actor="Mark Hamill" movie=;

// Query for all relations involving Mark Hamill
="Mark Hamill";

// Query for all relations and values from all memes relating to Mark Hamill:
="Mark Hamill" =;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A-value operators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String: &lt;code&gt;=&lt;/code&gt; &lt;code&gt;!=&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Numeric: &lt;code&gt;=&lt;/code&gt; &lt;code&gt;!=&lt;/code&gt; &lt;code&gt;&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;gt;=&lt;/code&gt; &lt;code&gt;&amp;lt;&lt;/code&gt; &lt;code&gt;&amp;lt;=&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firstName=Joe;
lastName!="David-Smith";
height&amp;gt;=1.6;
width&amp;lt;2;
weight!=150;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Comma-separated values produce an &lt;strong&gt;&lt;em&gt;OR&lt;/em&gt;&lt;/strong&gt; list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Query for (actor OR producer) = (Mark OR "Mark Hamill")
actor,producer=Mark,"Mark Hamill"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;R-relation operators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;!&lt;/code&gt; negates the relation name
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Query for Mark Hamill's non-acting relations
!actor="Mark Hamill";

// Query for an actor who is not Mark Hamill
actor!="Mark Hamill";

// Query all relations excluding actor and producer for Mark Hamill
!actor,producer="Mark Hamill"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A-Joins
&lt;/h3&gt;

&lt;p&gt;Open brackets &lt;code&gt;R1[R2&lt;/code&gt; join memes with equal &lt;code&gt;R1&lt;/code&gt; and &lt;code&gt;R2&lt;/code&gt; A-values. Open brackets need &lt;strong&gt;not&lt;/strong&gt; be closed, a semicolon closes all brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Generic example
R1=A1 R2[R3 R4&amp;gt;A4 A5=;

// Query for all of Mark Hamill's costars
actor="Mark Hamill" movie[movie actor=;

// Query for all movies in which both Mark Hamill and Carrie Fisher act together
actor="Mark Hamill" movie[movie actor="Carrie Fisher";

// Query for anyone who is both an actor and a producer
actor[producer;

// Query for a second cousin: child's parent's cousin's child
child= parent[cousin parent[child;

// Join any A-Value from the present meme to that A-Value in another meme
R1=A1 [ R2=A2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Joined queries return one meme with multiple &lt;code&gt;m=&lt;/code&gt; M-identifiers. Each &lt;code&gt;R=A&lt;/code&gt; belongs to the preceding &lt;code&gt;m=&lt;/code&gt; meme.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m=123 actor="Mark Hamill" movie="Star Wars" m=456 movie="Star Wars" actor="Harrison Ford";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Variables
&lt;/h3&gt;

&lt;p&gt;R-relations and A-values may be certain variable symbols. Variables &lt;em&gt;cannot&lt;/em&gt; be inside quotes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@&lt;/code&gt; Last matching A‑value&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;%&lt;/code&gt; Last matching R‑relation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#&lt;/code&gt; Current M-identifier
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Join two different memes where R1 and R2 have the same A-value (equivalent to R1[R2)
R1= m!=# R2=@;

// Two different R-relations have the same A-value
R1= R2=@;

// The first A-value is the second R-relation
R1= @=A2;

// The first R-relation equals the second A-value
=A1 R2=%;

// The pattern is run twice (redundant)
R1=A1 %=@;

// The second A-value may be Jeff or the previous A-value
R1= R2=Jeff,@;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  M-Joins
&lt;/h3&gt;

&lt;p&gt;Explicit joins are controlled using &lt;code&gt;m&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;m=#&lt;/code&gt; present meme (implicit default)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;m!=#&lt;/code&gt; join to a different meme&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;m=&lt;/code&gt; join to any meme (including the present)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;m=^#&lt;/code&gt; (or &lt;code&gt;]&lt;/code&gt;) resets &lt;code&gt;m&lt;/code&gt; and &lt;code&gt;#&lt;/code&gt; to the previous meme, acts as &lt;em&gt;unjoin&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Join two different memes where R1 and R2 have the same A-value (equivalent to R1[R2)
R1= m!=# R2=@;

// Join any memes (including the present one) where R1 and R2 have the same A-value
R1= m= R2=@;

// Join two different memes, unjoin, join a third meme (equivalent statements)
R1[R2] R3[R4;
R1= m!=# R2=@ m=^# R3= m!=# R4=@;

// Unjoins may be sequential (equivalent statements)
R1[R2 R3[R4]] R5=;
R1= m!=# R2=@ R3= m!=# R4=@ m=^# m=^# R5=;
R1= m!=# R2=@ R3= m!=# R4=@ m=^# ] R5=;
R1= m!=# R2=@ R3= m!=# R4=@ ]] R5=;

// Join two different memes on R1=R2, unjoin, then join the first meme to another where R4=R5
R1= m!=# R2=@ R3= m=^# R4= m!=# R5=@;

// Query for a meta-meme, R2's A-value is R1's M-identifier
R1=A1 m= R2=#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SQL Comparisons
&lt;/h3&gt;

&lt;p&gt;Memelang queries are significantly shorter and clearer than equivalent SQL queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;movie="Star Wars" actor= role= rating&amp;gt;4;
SELECT actor, role FROM memes WHERE movie = 'Star Wars' AND rating &amp;gt; 4;

role="Luke Skywalker","Han Solo" actor=;
SELECT actor FROM movies WHERE role IN ('Luke Skywalker', 'Han Solo');

producer,actor="Mark Hamill","Harrison Ford" movie[movie actor=
SELECT m1.actor, m1.movie, m2.actor FROM movies m1 JOIN movies m2 ON m1.movie = m2.movie WHERE m1.actor IN ('Mark Hamill', 'Harrison Ford') or m1.producer IN ('Mark Hamill', 'Harrison Ford');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  More
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://memelang.net/05/" rel="noopener noreferrer"&gt;https://memelang.net/05/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/memelang-net/memesql5/" rel="noopener noreferrer"&gt;https://github.com/memelang-net/memesql5/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>graphql</category>
      <category>cypher</category>
      <category>memelang</category>
    </item>
  </channel>
</rss>
