Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 873683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:58:48+00:00 2026-05-15T10:58:48+00:00

Say I got an traditional SQL structure like so: create table tags (id PRIMARY

  • 0

Say I got an traditional SQL structure like so:

create table tags (id PRIMARY KEY int, tag varchar(100));
create table files (id PRIMARY KEY int, filename varchar(500));
create table tagged_files (tag_id int, file_id int);

I add some tags:

insert into table tags (tag) values ('places');
insert into table tags (tag) values ('locations');

And some files:

insert into table files (filename) values ('/tmp/somefile');
insert into table files (filename) values ('/tmp/someotherfile');

and then tag these files:

insert into table tagged_files (tag_id, file_id) values (1,1);
insert into table tagged_files (tag_id, file_id) values (1,2);

Then I can find all the files tagged with the first tag like so:

select * from files, tagged_files where id = file_id and tag_id = 1

But how do I do the same thing using NoSQL solutions like MongoDB and CouchDB?? And what NoSQL project is best suited for something like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:58:48+00:00Added an answer on May 15, 2026 at 10:58 am

    For MongoDB.

    Chances are you’d simply save them with the tags as:

    db.Files.save({ "fn" : "/tmp/somefile", "ts" : [ { "t" : "places" }, { "t" : "locations" }] });
    db.Files.save({ "fn" : "/tmp/someotherfile", "ts" : [ { "t" : "locations" }] });
    

    Alternative is to save tags separately (ObjectId’s are 12 bytes iirc):

    db.Tags.save({ "t" : "places" });
    db.Tags.save({ "t" : "locations" });
    db.Files.save({ "fn" : "/tmp/somefile", "t" : [ { "i" : ObjectId("IdOfPlaces") }, { "i" : ObjectId("IdOfLocations") }] });
    

    In both cases to get a file it’s

    db.Files.find({ "_id" : ObjectId("4c19e79e244f000000007e0d") });
    db.Files.find({ "fn" : "/tmp/somefile" });
    

    Or a couple files based on tags:

    db.Files.find({ ts : { t : "locations" } })
    db.Files.find({ t : { i : ObjectId("4c19e79e244f000000007e0d") } })
    

    Examples are from the mongo console. And if you store tags with Id’s you’d obviously have to read the tags up based on the Id’s once you got the file(s).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 450k
  • Answers 450k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First off: the simple, reliable way to do this is… May 15, 2026 at 8:35 pm
  • Editorial Team
    Editorial Team added an answer URLRequest prepares a url to be used by any service… May 15, 2026 at 8:35 pm
  • Editorial Team
    Editorial Team added an answer Try: $("#"+styleTarget).css({ 'font-size': $(this).val() }); By putting the value in… May 15, 2026 at 8:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.