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 6927145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:00:38+00:00 2026-05-27T11:00:38+00:00

I am creating a blog system in Node.js with mongodb as the db. I

  • 0

I am creating a blog system in Node.js with mongodb as the db.

I have contents like this: (blog articles):

// COMMENTS SCHEMA:
// ---------------------------------------
var Comments = new Schema({

    author: {
        type: String
    },
    content: {
        type: String
    },
    date_entered: {
        type: Date,
        default: Date.now
    }

});
exports.Comments = mongoose.model('Comments',Comments);
var Tags = new Schema({ 
    name: {
        type: String
    } 
});
exports.Tags = mongoose.model('Tags',Tags);


// CONTENT SCHEMA:
// ---------------------------------------
exports.Contents = mongoose.model('Contents', new Schema({

    title: {
        type: String
    },
    author: {
        type: String
    },
    permalink: {
        type: String, 
        unique: true,
        sparse: true
    },
    catagory: {
        type: String,
        default: ''
    },
    content: {
        type: String
    }, 
    date_entered: {
        type: Date,
        default: Date.now
    }, 
    status: {
        type: Number
    },
    comments: [Comments],
    tags: [Tags]

}));

I am a little new to this type of database, im used to MySQL on a LAMP stack.

Basically my question is as follows:

  • whats the best way to associate the Contents author to a User in the
    DB?
  • Also, whats the best way to do the tags and categories?

In MYSQL we would have a tags table and a categories table and relate by keys, I am not sure the best and most optimal way of doing it in Mongo.

THANK YOU FOR YOUR TIME!!

  • 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-27T11:00:39+00:00Added an answer on May 27, 2026 at 11:00 am

    Couple of ideas for Mongo:

    • The best way to associate a user is e-mail address – as an attribute of the content/comment document – e-mail is usually a reliable unique key. MongoDB doesn’t have foreign keys or associated constraints. But that is fine.
    • If you have a registration policy, add user name, e-mail address and other details to the users collection. Then de-normalize the content document with the user name and e-mail. If, for any reason, the user changes the name, you will have to update all the associated contents/comments. But so long as the e-mail address is there in the documents, this should be easy.
    • Tags and categories are best modelled as two lists in the content document, IMHO.
    • You can also create two indices on these attributes, if required. Depends on the access patterns and the UI features you want to provide
    • You can also add a document which keeps a tag list and a categories list in the contents collection and use $addToSet to add new tags and categories to this document. Then, you can show a combo box with the current tags as a starting point.
    • As a final point, think through the ways you plan to access the data and then design documents, collections & indices accordingly
    • [Update 12/9/11] Was at MongoSv and Eliot (CTO 10gen) presented a pattern relevant to this question: Instead of one comment document per user (which could grow large) have a comment document per day for a use with _id = -YYYYMMDD or even one per month depending on the frequency of comments. This optimizes index creation/document growth vs document proliferation (in case of the design where there is one comment per user).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm creating a pagination system for a blog-like system. I already have the
Creating a simple blog application, I have this partial .comment %p %b Namn: =
I am creating an online blog website and for each blog post, I'd like
I am currently in the process of creating my own blog and I have
I have a cakePhp application built, and now I'm creating a simple blog based
I've been creating a blog using tutorials around the web and I have a
I am creating a wordpress blog for a magazine. They have a legacy blog
I'm currently creating blog system, which I hope to turn into a full CMS
I was following the screencast on rubyonrails.org (creating the blog). I have following models:
I am creating a blog based on the 960 grid system. It has three

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.