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

  • SEARCH
  • Home
  • 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 8478329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:42:57+00:00 2026-06-10T18:42:57+00:00

I am designing my first MongoDB (and first NoSQL) database and would like to

  • 0

I am designing my first MongoDB (and first NoSQL) database and would like to store information about files in a collection. As part of each file document, I would like to store a log of file accesses (both reads and writes).

I was considering creating an array of log messages as part of the document:

{
    "filename": "some_file_name",
    "logs" : [
        { "timestamp": "2012-08-27 11:40:45", "user": "joe", "access": "read" },
        { "timestamp": "2012-08-27 11:41:01", "user": "mary", "access": "write" },
        { "timestamp": "2012-08-27 11:43:23", "user": "joe", "access": "read" }
    ]
}

Each log message will contain a timestamp, the type of access, and the username of the person accessing the file. I figured that this would allow very quick access to the logs for a particular file, probably the most common operation that will be performed with the logs.

I know that MongoDB has a 16Mbyte document size limit. I imagine that files that are accessed very frequently could push against this limit.

Is there a better way to design the NoSQL schema for this type of logging?

  • 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-06-10T18:42:58+00:00Added an answer on June 10, 2026 at 6:42 pm

    Lets first try to calculate avg size of the one log record:

    timestamp word = 18, timestamp value = 8, user word = 8, user value=20 (10 chars it is max(or avg for sure) I guess), access word = 12, access value 10. So total is 76 bytes. So you can have ~220000 of log records.

    And half of physical space will be used by field names. In case if you will name timestamp = t, user = u, access=a — you will be able to store ~440000 of log items.

    So, i think it is enough for the most systems. In my projects I always trying to embed rather than create separate collection, because it a way to achieve good performance with mongodb.

    In the future you can move your logs records into separate collection. Also for performance you can have like a 30 last log records (simple denormalize them) in file document, for fast retrieving in addition to logs collection.

    Also if you will go with one collection, make sure that you not loading logs when you no need them (you can include/exclude fields in mongodb). Also use $slice to do paging.

    And one last thing: Enjoy mongo!

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

Sidebar

Related Questions

I'm designing a database application which stores simple contact information (First/Last Name etc.) and
First I would like to explain why I want to use alternate Blackberry Persistance
I am designing my database using code first and I need a little help
first of all I would like to thank you for the many good posts
I'm designing my first API for a web app based on a MongoDB datastore.
I'm designing my first database for MySQL and the idea here is that we
This is my first time designing tables in a sql database and I have
I have been trying the model-first method when designing my application. We usually like
I am currently working on designing my first FPS game using JOGL. (Java bindings
I am designing a web application using GWT currently, which is also the first

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.