DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. RavenDB: What are Tertiary Includes

RavenDB: What are Tertiary Includes

Oren Eini user avatar by
Oren Eini
·
Jul. 05, 12 · Interview
Like (0)
Save
Tweet
Share
3.39K Views

Join the DZone community and get the full member experience.

Join For Free

for a while, i was absolutely against this, in fact, i refused to implement this several times when asked, because it is complicate to do and indicate design problems in your domain model.

during a course today, i found out that i might want to refuse, but the feature is actually in the product for the last two+ years, we just didn’t know about this.

but what are tertiary includes in the first place?

let us imagine that we have something like this:

image

now, i want to load an order, but also show its customer and products. those are secondary includes, and are very easy to do with ravendb:

var orders = session.query<order>()
                  .include("customer")
                  .include("lines,product")
                  .tolist(); 

there is also a strongly typed option for this, of course.

what this does is instruct ravendb to load into the session the customer and the associated products into the session, so when you do something like this:

var cust = session.load<customer>(order.customer);

the value will be loaded from the session cache, without going to the sever. as i said, this is a feature that we have had for quite a while, and it is a really nice one, because it drastically reduce the number of queries that you have to make.

the problem is that some people want to take it one step further, they want to be able to search on an order, but also load the location of a product. i don’t really like this, and as i said, when asked for this feature, i consistently said that it isn’t there because it represent a remnant of relational thinking in your design.

but as it turned out, we do support this, although quite by accident.

the reason is quite simple, we evaluate includes only after we evaluate the tranformresults function. which means that the tranformresults function gets to choose whatever you want to include. here is how it works:

    tranformresults  = (database, results) =>
       from result in results
       select new 
       {
         order = result,
         locations = result.selectmany(x=>x.lines).select(x=>database.load<product>(x.product).location)
       }

and then, you can just ask to include(“locations”), and you are pretty much set.

except, that this is a really awkward thing to do, and i don’t really like it at all.

sure, i don’t like this feature, but people will use it, and if it already there, we might as well make it elegant. therefor, we now have the option of doing:

    tranformresults  = (database, results) =>
       from result in results
       let _ = database.include(result.selectmany(x=>x.lines).select(x=>x.product))
       select result;

i think you’ll agree that this is much nicer all around, this tells the server to include the data, without us needing to explicitly ask this from the client.

Session (web analytics) Design Relational database Cache (computing) Data (computing)

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How To Check Docker Images for Vulnerabilities
  • A Brief Overview of the Spring Cloud Framework
  • ChatGPT Prompts for Agile Practitioners
  • Top 10 Secure Coding Practices Every Developer Should Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: