-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Denormalization support? Discuss, review or feedback #6096
Comments
@clarkorz thanks for the detailed review. To clarify- is the idea to keep track of the other model in the standard association methodology, as well as embedding it? Or is this just straight-up embed? From a 1000 foot view, I'd say the latter would be a bit simpler to implement, but curious to hear your thoughts. |
@clarkorz (ps- haven't looked at the PR yet, but we'll look at is as soon as we can). Thanks! |
@clarkorz thanks this sounds like a nice solution for mongo. I'll have to spend some time going through the PR's and understanding what all is happening. I'll try to get this into the next rc release if it makes sense and there is time. |
@mikermcneil sorry, not an English speaker, have trouble to understand the phrase "straight-up embed", is that means "embed the model fully without storing it in an separated collection"? If my guess is right, then NO, my idea is more like the former one. The One side model stores its records in its own collection, while the Many side model caches a few attributes of the associated One model. I use the word embed because sub-documents are embedded in a parent document. My idea is the same as this article, in case I use grammar wrong (I almost confuse myself &_& |
@particlebanana thanks~ I think this feature needs some more work.
|
@particlebanana @clarkorz Het guys, I'm here from Mongoose.js background. Any updates on this? I'd love to help if possible either with making associations/embeds happen or with docs. |
@edwardhotchkiss I have only finished the btw, do you think that |
For anyone who's wanting a little clarification on all of this, THIS is a good read: http://blog.mongodb.org/post/87892923503/6-rules-of-thumb-for-mongodb-schema-design-part-2. (Read parts 1 and 3 as well if you want.) Essentially, it's very common in the Mongo world to do denormalization (embeds). All based on need. If your data is limited, (one user has just a few addresses) it can make a lot of sense to just embed those addresses. On the other hand, joins can be needed where lots (gazillions) of independent data needs to work together. Another scenario (not denormalization, but sort of like it) is to support parent arrays of child ids. I don't think Waterline does this either. I'd love to find out I'm wrong, since I need that exact functionality right now. (Will be happy to open a separate ticket to discuss that exact need.) |
Another scenario is denormalizing many to many relationship data: http://seanhess.github.io/2012/02/01/mongodb_relational.html#many-to-many-relationships |
@clarkorz still at a stand still with this? |
Thanks for posting, @clarkorz. I'm a repo bot-- nice to meet you! It has been 60 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
Bump. This can be extremely useful and I've found myself in need of this. What's the status? |
Thanks for posting, @clarkorz. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
This is a placeholder for ecosystem-wide PRs that have been around for a long time, so I think we have to keep this open so that those PRs aren't orphaned. |
Thanks for posting, @clarkorz. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
When using mongodb, it's very common to use denormalizated schema, to make single database query for each request.
For example,
User
model may have many properties (displayName, avatar, location, address, cellphone, ...),Blog
model has anauthor
attribute to associate withUser
model, but not only withuser.id
, but alsouser.displayName
. If Listing Blogs only need to display user's name, thenGET /blogs
request only need to queryblogs
collection ONCE without queryingusers
collection. Of cause there is cost: data redundancy. But user won't change theirdisplayName
every day.Hence I think it will be great that sails could support denormalization.
My teammates were going to replace associations with simple sub-documents, until I worked out certain commits on waterline, waterline-schema, and sails-mongo.
The idea is to add an
embed
property on association config, it can has an array of attribute names, then the child model (with specific properties ONLY) will be embed to the parent model, and this embedded document can representchildKey
(orforeignKey
). Basically, using association api just like before( with foreign key, saved model object, or new model object), then the associated models will be saved and retrieved as sub-document of parent models in mongodb, instead of just foreign keys.The text was updated successfully, but these errors were encountered: