์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[MongoDB] Model Relationships Between Documents (1)

๐Ÿ˜Ž ์ง€์‹ in Action/React, Typescript, Javascript ๐ŸŒ

by :ํ•ดํ”ผ๋ž˜๋น—๐Ÿพ 2021. 6. 10. 12:48

๋ณธ๋ฌธ

728x90
// student document
{
	_id : 'ohnamju_01',
	name : 'ohnamju'
}

// account document
{
	account_id : 'ohnamju_01',
	balance : 0,
}

/* ์ž์ฃผ account ์ •๋ณด์—์„œ name์ด ํ•„์š”ํ•˜๋‹ค๋ฉด, */
{
	_id : 'ohnamju_01',
	name : 'ohnamju'
	balance: 0
}

- ๋ฌธ์ œ์  : ํ•„์š”ํ•˜์ง€ ์•Š์€ ๋ฐ์ดํ„ฐ๋„ load ์‹œ์ผœ read๋ฅผ ์ˆ˜ํ–‰ํ•  ๋•Œ ๋А๋ ค์งˆ ์ˆ˜ ์žˆ์Œ.

the most frequently-accessed portion of the data should go in the collection that the application loads first.

์ œ์ผ ์ค‘์š”ํ•œ ์ ์€ ์šฐ๋ฆฌ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์–ด๋–ป๊ฒŒ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š”์ง€์— ์ดˆ์ ์„ ๋งž์ถฐ์„œ ์„ค๊ณ„ํ•˜๋Š” ๊ฒƒ

์˜ˆ์‹œ) movie ์™€ movie detail๋กœ ๋‚˜๋ˆ„์ž

๋”๋ณด๊ธฐ
// movie collection
{
	"id" : 1,
	"title" : "The Arrival of a Train",
	"year" : 1895,
	"runtime" : 1,
	"released" : IsoDate("1895-01-25")
	"type": "movie",
 	"directors": [ "Auguste Lumière", "Louis Lumière" ],
	"countries": [ "France" ],
	"genres": [ "Documentary", "Short" ],
}

// movie_details collection
{
  "_id": 156,
  "movie_id": 1, // reference to the movie collection
  "poster": "http://ia.media-imdb.com/images/M/MV5BMjEyNDk5MDYzOV5BMl5BanBnXkFtZTgwNjIxMTEwMzE@._V1_SX300.jpg",
  "plot": "A group of people are standing in a straight line along the platform of a railway station, waiting for a train, which is seen coming at some distance. When the train stops at the platform, ...",
  "fullplot": "A group of people are standing in a straight line along the platform of a railway station, waiting for a train, which is seen coming at some distance. When the train stops at the platform, the line dissolves. The doors of the railway-cars open, and people on the platform help passengers to get off.",
  "lastupdated": ISODate("2015-08-15T10:06:53"),
  "imdb": {
    "rating": 7.3,
    "votes": 5043,
    "id": 12
  },
  "tomatoes": {
    "viewer": {
      "rating": 3.7,
      "numReviews": 59
    },
    "lastUpdated": ISODate("2020-01-29T00:02:53")
  }
}

 

 

728x90

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ