Slide 31
Slide 31 text
of
{
name: Joe,
url: '...',
stream:
[{
user: {name: Jane, url: '...'},
title: 'today',
body: 'go fly a kite',
likes: [
{user: {name: Lu, url: '...'}},
{user: {name: Joe, url: '...'}}
],
}]
}
JOE’S SLIGHTLY MORE NORMALIZED STREAM
id: 1,
2,
3},
1},
31
...you give each user an ID, here at the top - as an aside, Mongo actually uses BSON IDs,
which are strings sort of like GUIDs, but to make the slides easier to read I’m just using
integers. So once users have IDs, we store the user’s ID every place that we were previously
inlining data.
So this eliminates our duplication problem - now, when user data changes, there’s only one
place we have to change it. However, now we can't get all the information we need to
construct an activity stream from a single document. Our efficiency has been reduced, and
our complexity has been increased, because now to construct the activity stream, we have to
retrieve the stream document, and then go back and retrieve all the user documents that the
stream references, to get their user data.
And what you really want, here...