Home:ALL Converter>Proper tree NoSQL structure with focus on full-text searching

Proper tree NoSQL structure with focus on full-text searching

Ask Time:2014-11-12T06:55:35         Author:Deepsy

Json Formatter

I developing an app with tree(folder-file) structure, on which I should perform full-text searches with MongoDB. I did a research on the best tree structure practices and found this great article, but I still can not decide which DB structure will fit my needs.

I have the following requirements in my mind:

  • I should be able to perform full-text search on individual folders, as well as everything from specific users
  • The folders/files should be shareable, so I need to be able to perform full-text search on all items accessible by specific user

I've been thinking about the following structures.

Structure 1

Fields of Users collection

 1. _id - objectid
 2. name - string

Fields of Folders collection

 1. _id - objectid
 2. name - string
 3. owner - objectid
 4. sharedWith - array of objectIds
 5. location - objectid of parent folder, null if in root
 6. createDate - datetime

Fields of File collection

 1. _id - objectid
 2. name - string
 3. owner - objectid
 4. sharedWith - array of objectIds
 5. data - string
 6. location - objectId of folder
 7. createDate - datetime

So here comes my questions:

  1. Should I use model tree structures with Parent References or Child References?
  2. Should I use 1 collection for both files and folders(with type field) or I should separate them.
  3. Does it worth to have only folder collection and nest documents in it.

This were my most important questions, thought I will greatly appreciate any advice on how I can improve the structure. I'm sorry if this isn't the right place to ask such questions.

Author:Deepsy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26876154/proper-tree-nosql-structure-with-focus-on-full-text-searching
yy