I had a great time at the recent MarkLogic conference and wanted to share just one thing: joins are not dead!  If you’re like me, you’ve spent the last 20 years working with relational databases.  When I first looked at MarkLogic, I was shocked (dismayed?) that there was no clear way to join tables.  Why?  Because there are no tables!?!?  Instead, we just have this mass of documents, some of which might contain data describing a <person> while others contain data describing a <car>.

So how do I indicate that the person owns the car?  For example: “John Smith owns the awesome red Camaro”.

If I had my friendly, comfortable relational database, I would either:

a) Create a foreign key in the person called “ownscar”,

b) Add a foreign key to the person table called “owner” or

c) Create a many-many relationship between the car table and the person table

Then I would update the tables as needed to establish the relationship.  Voila!  But with MarkLogic, I’m stuck because there is nothing called a “join”.  Oh no!  Can’t I please go back to Oracle?  But wait a minute, I chose MarkLogic because of a myriad of great features that impact my productivity in a massively positive way.  But I need a join!!


Semantics are *so* cool!  With semantics, I get my join back; albeit with a different name: semantics.  Semantics allow me to create relationships between entities just like I used to do in the relational worldwhile still taking advantages of the great features of MarkLogic.  With semantics, I create a relationship this way: <subject> : <predicate> : <object>; this is called a “triple”.  In my case, the relationship is represented by a semantic triple like this: <John Smith> : <Owns>: <Awesome Red Camaro>.  And I can do this without *any* update to my existing data.  This rocks!  Not only that, what if I want a different kind of relationship?  Like this: <Mark Nice> : <Borrowed> : <Awesome Red Camaro>.  You might say: “But Todd, then you have to change the schema to accommodate the new relationship!”  Wrong!  With MarkLogic Semantics, I can create any kind of relationship between any number of entities without ever changing the schema!

If this sounds cool to you, check out this video from the MarkLogic World 2015:

Multi-Model Data Integration in the Real World; A Modern Approach to Data Modeling with MarkLogic

So if someone tells you that joins are gone in MarkLogic, just tell them it’s just a matter of semantics 🙂