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. Culture and Methodologies
  3. Agile
  4. How to Handle Complex Tagging in RavenDB

How to Handle Complex Tagging in RavenDB

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

Join the DZone community and get the full member experience.

Join For Free

in the ravendb mailing list, we got a question about tagging. in this case, the application need:

1. tags have identity  ("set" has a different meaning if i'm talking math, music or sports).

2. i want to know who tagged what and when.

3. i want to do this once, as a service, so i don’t need have ids in each document i want to tag. in my app, there are many such document types.

let us see how we can approach this in ravendb. we are going to do it like so:

image image

note that because tags have identity, we store only the tag id inside the tagged object, along with the required information about who & when it was tagged.

now, let us try to have some fun with this. let us say that i want to be able to show, given a specific album, all the albums that have any of the same tags as the specified album.

we start by defining the following index:

image

note that the naming convention matches what we would expect using the default linq convention, so we can easily query this index using linq.

and now we want to query it, which, assuming that we are starting with albums/1, will look like:

image

this translate to “show me all of the albums that share any of the specified tags, except albums/1”.

and this is pretty much it, to be fair. oh, if you want to show the tags names you’ll have to include the actual tags documents, but there really isn’t anything complex going on.

but what about the 3rd requirement?

well, it isn’t really meaningful. you can move this tags collection to a the layer super type, but if you want to be able to do nice tagging with ravendb, this is probably the easiest way to go.

Document Database app application Requirement Object (computer science)

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

  • PostgreSQL: Bulk Loading Data With Node.js and Sequelize
  • Continuous Development: Building the Thing Right, to Build the Right Thing
  • AIOps Being Powered by Robotic Data Automation
  • Project Hygiene

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: